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
fa45cc42
Commit
fa45cc42
authored
Sep 22, 2018
by
Ukrainskiy Sergey
Committed by
Yukihiro "Matz" Matsumoto
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dependencies
parent
d67d2ae8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
6 deletions
+29
-6
mrbgems/default.gembox
mrbgems/default.gembox
+0
-6
mrbgems/mruby-complex/mrbgem.rake
mrbgems/mruby-complex/mrbgem.rake
+1
-0
mrbgems/mruby-rational/mrbgem.rake
mrbgems/mruby-rational/mrbgem.rake
+1
-0
mrbgems/mruby-rational/mrblib/rational.rb
mrbgems/mruby-rational/mrblib/rational.rb
+12
-0
mrbgems/mruby-rational/test/rational.rb
mrbgems/mruby-rational/test/rational.rb
+15
-0
No files found.
mrbgems/default.gembox
View file @
fa45cc42
...
...
@@ -68,12 +68,6 @@ MRuby::GemBox.new do |conf|
# Use Enumerator::Lazy class (require mruby-enumerator)
conf.gem :core => "mruby-enum-lazy"
# Use Complex class
# conf.gem :core => "mruby-complex"
# Use Rational class
# conf.gem :core => "mruby-rational"
# Use toplevel object (main) methods extension
conf.gem :core => "mruby-toplevel-ext"
...
...
mrbgems/mruby-complex/mrbgem.rake
View file @
fa45cc42
...
...
@@ -3,6 +3,7 @@ MRuby::Gem::Specification.new('mruby-complex') do |spec|
spec
.
author
=
'mruby developers'
spec
.
summary
=
'Complex class'
spec
.
add_dependency
'mruby-metaprog'
,
core:
'mruby-metaprog'
spec
.
add_dependency
'mruby-object-ext'
,
core:
'mruby-object-ext'
spec
.
add_dependency
'mruby-numeric-ext'
,
core:
'mruby-numeric-ext'
spec
.
add_dependency
'mruby-math'
,
core:
'mruby-math'
...
...
mrbgems/mruby-rational/mrbgem.rake
View file @
fa45cc42
...
...
@@ -3,6 +3,7 @@ MRuby::Gem::Specification.new('mruby-rational') do |spec|
spec
.
author
=
'mruby developers'
spec
.
summary
=
'Rational class'
spec
.
add_dependency
'mruby-metaprog'
,
core:
'mruby-metaprog'
spec
.
add_dependency
'mruby-object-ext'
,
core:
'mruby-object-ext'
spec
.
add_dependency
'mruby-numeric-ext'
,
core:
'mruby-numeric-ext'
end
mrbgems/mruby-rational/mrblib/rational.rb
View file @
fa45cc42
...
...
@@ -10,6 +10,18 @@ class Rational < Numeric
"(
#{
to_s
}
)"
end
def
to_f
@numerator
.
to_f
/
@denominator
.
to_f
end
def
to_i
to_f
.
to_i
end
def
to_r
self
end
def
to_s
"
#{
numerator
}
/
#{
denominator
}
"
end
...
...
mrbgems/mruby-rational/test/rational.rb
View file @
fa45cc42
...
...
@@ -9,6 +9,21 @@ assert 'Rational' do
assert_equal
[
r
.
numerator
,
r
.
denominator
],
[
5
,
1
]
end
assert
'Rational#to_f'
do
assert_float
Rational
(
2
).
to_f
,
2.0
assert_float
Rational
(
9
,
4
).
to_f
,
2.25
assert_float
Rational
(
-
3
,
4
).
to_f
,
-
0.75
assert_float
Rational
(
20
,
3
).
to_f
,
6.666666666666667
end
assert
'Rational#to_i'
do
assert_equal
Rational
(
2
,
3
).
to_i
,
0
assert_equal
Rational
(
3
).
to_i
,
3
assert_equal
Rational
(
300.6
).
to_i
,
300
assert_equal
Rational
(
98
,
71
).
to_i
,
1
assert_equal
Rational
(
-
30
,
2
).
to_i
,
-
15
end
assert
'Rational#*'
do
assert_rational
Rational
(
2
,
3
)
*
Rational
(
2
,
3
),
Rational
(
4
,
9
)
assert_rational
Rational
(
900
)
*
Rational
(
1
),
Rational
(
900
,
1
)
...
...
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