Skip to content

Commit 4296e88

Browse files
committed
Update RDF::Literal::Decimal#round, #floor, #ceil to return integers along with RDF::Literal::Double variations. Previously, they returned the same type.
1 parent 5f45c98 commit 4296e88

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

lib/rdf/model/literal/decimal.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def abs
6363
##
6464
# Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
6565
#
66-
# @return [RDF::Literal]
66+
# @return [RDF::Literal::Integer]
6767
def round
68-
self.class.new(to_d.round)
68+
RDF::Literal::Integer.new(to_d.round)
6969
end
7070

7171
##
@@ -74,7 +74,7 @@ def round
7474
# @example
7575
# RDF::Literal(1).ceil #=> RDF::Literal(1)
7676
#
77-
# @return [RDF::Literal]
77+
# @return [RDF::Literal::Integer]
7878
def ceil
7979
self.class.new(to_d.ceil)
8080
end
@@ -85,7 +85,7 @@ def ceil
8585
# @example
8686
# RDF::Literal(1).floor #=> RDF::Literal(1)
8787
#
88-
# @return [RDF::Literal]
88+
# @return [RDF::Literal::Integer]
8989
def floor
9090
self.class.new(to_d.floor)
9191
end

lib/rdf/model/literal/double.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,33 +142,33 @@ def infinite?
142142
end
143143

144144
##
145-
# Returns the smallest number greater than or equal to `self`.
145+
# Returns the smallest integer greater than or equal to `self`.
146146
#
147147
# @example
148148
# RDF::Literal(1.2).ceil #=> RDF::Literal(2)
149149
# RDF::Literal(-1.2).ceil #=> RDF::Literal(-1)
150150
# RDF::Literal(2.0).ceil #=> RDF::Literal(2)
151151
# RDF::Literal(-2.0).ceil #=> RDF::Literal(-2)
152152
#
153-
# @return [RDF::Literal]
153+
# @return [RDF::Literal::Integer]
154154
# @since 0.2.3
155155
def ceil
156-
self.class.new(to_f.ceil)
156+
RDF::Literal::Integer.new(to_f.ceil)
157157
end
158158

159159
##
160-
# Returns the largest number less than or equal to `self`.
160+
# Returns the largest integer less than or equal to `self`.
161161
#
162162
# @example
163163
# RDF::Literal(1.2).floor #=> RDF::Literal(1)
164164
# RDF::Literal(-1.2).floor #=> RDF::Literal(-2)
165165
# RDF::Literal(2.0).floor #=> RDF::Literal(2)
166166
# RDF::Literal(-2.0).floor #=> RDF::Literal(-2)
167167
#
168-
# @return [RDF::Literal]
168+
# @return [RDF::Literal::Integer]
169169
# @since 0.2.3
170170
def floor
171-
self.class.new(to_f.floor)
171+
RDF::Literal::Integer.new(to_f.floor)
172172
end
173173

174174
##
@@ -181,11 +181,11 @@ def abs
181181
end
182182

183183
##
184-
# Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
184+
# Returns the integer with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
185185
#
186-
# @return [RDF::Literal]
186+
# @return [RDF::Literal::Integer]
187187
def round
188-
self.class.new(to_f.round)
188+
RDF::Literal::Integer.new(to_f.round)
189189
end
190190

191191
##

0 commit comments

Comments
 (0)