Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
abb4e583
Commit
abb4e583
authored
May 26, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #198 from bovi/add-compar-doc
Add documentation to Comparable
parents
f6d539ea
c1faad90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
8 deletions
+44
-8
mrblib/compar.rb
mrblib/compar.rb
+44
-8
No files found.
mrblib/compar.rb
View file @
abb4e583
##
# Comparable
#
# ISO 15.3.3
module
Comparable
# 15.3.3.2.1
##
# Return true if +self+ is less
# than +other+. Otherwise return
# false.
#
# ISO 15.3.3.2.1
def
<
other
cmp
=
self
<=>
other
if
cmp
.
nil?
...
...
@@ -11,7 +21,12 @@ module Comparable
end
end
# 15.3.3.2.2
##
# Return true if +self+ is less
# than or equal to +other+.
# Otherwise return false.
#
# ISO 15.3.3.2.2
def
<
=
other
cmp
=
self
<=>
other
if
cmp
.
nil?
...
...
@@ -23,7 +38,12 @@ module Comparable
end
end
# 15.3.3.2.3
##
# Return true if +self+ is equal
# to +other+. Otherwise return
# false.
#
# ISO 15.3.3.2.3
def
==
other
cmp
=
self
<=>
other
if
cmp
==
0
...
...
@@ -33,7 +53,12 @@ module Comparable
end
end
# 15.3.3.2.4
##
# Return true if +self+ is greater
# than +other+. Otherwise return
# false.
#
# ISO 15.3.3.2.4
def
>
other
cmp
=
self
<=>
other
if
cmp
.
nil?
...
...
@@ -45,9 +70,14 @@ module Comparable
end
end
# 15.3.3.2.5
##
# Return true if +self+ is greater
# than or equal to +other+.
# Otherwise return false.
#
# ISO 15.3.3.2.5
def
>
=
other
cmp
=
self
<=>
other
cmp
=
self
<=>
other
if
cmp
.
nil?
false
elsif
cmp
>=
0
...
...
@@ -57,8 +87,14 @@ module Comparable
end
end
# 15.3.3.2.6
def
between?
(
min
,
max
)
##
# Return true if +self+ is greater
# than or equal to +min+ and
# less than or equal to +max+.
# Otherwise return false.
#
# ISO 15.3.3.2.6
def
between?
(
min
,
max
)
if
self
<
min
or
self
>
max
false
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment