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
c1faad90
Commit
c1faad90
authored
May 27, 2012
by
Daniel Bovensiepen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation to Comparable
parent
f6d539ea
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 @
c1faad90
##
# Comparable
#
# ISO 15.3.3
module
Comparable
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
def
<
other
cmp
=
self
<=>
other
cmp
=
self
<=>
other
if
cmp
.
nil?
if
cmp
.
nil?
...
@@ -11,7 +21,12 @@ module Comparable
...
@@ -11,7 +21,12 @@ module Comparable
end
end
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
def
<
=
other
cmp
=
self
<=>
other
cmp
=
self
<=>
other
if
cmp
.
nil?
if
cmp
.
nil?
...
@@ -23,7 +38,12 @@ module Comparable
...
@@ -23,7 +38,12 @@ module Comparable
end
end
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
def
==
other
cmp
=
self
<=>
other
cmp
=
self
<=>
other
if
cmp
==
0
if
cmp
==
0
...
@@ -33,7 +53,12 @@ module Comparable
...
@@ -33,7 +53,12 @@ module Comparable
end
end
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
def
>
other
cmp
=
self
<=>
other
cmp
=
self
<=>
other
if
cmp
.
nil?
if
cmp
.
nil?
...
@@ -45,9 +70,14 @@ module Comparable
...
@@ -45,9 +70,14 @@ module Comparable
end
end
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
def
>
=
other
cmp
=
self
<=>
other
cmp
=
self
<=>
other
if
cmp
.
nil?
if
cmp
.
nil?
false
false
elsif
cmp
>=
0
elsif
cmp
>=
0
...
@@ -57,8 +87,14 @@ module Comparable
...
@@ -57,8 +87,14 @@ module Comparable
end
end
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
if
self
<
min
or
self
>
max
false
false
else
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