Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# RELEASE HISTORY


## Unreleased (0.3.1)

Changes:

* Fix negative numbers, which raised NoMethodError when converted to a
string: `(-4).to_roman.to_s` is now `-IV`. (Bartosz Dziewoński, #1)


## 0.3.0 / 2026-04-02

Maintenance release. Modernized project tooling.
Expand Down
2 changes: 1 addition & 1 deletion lib/roman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RomanNumeral < Numeric
#
def self.from_integer(int)
#return nil if integer > MAX
return "-#{(-int).roman}" if int < 0
return "-#{(-int).to_roman}" if int < 0
return "" if int == 0
ROMAN_VALUES_ASSOC.each do |(i, v)|
return(i + from_integer(int-v)) if v <= int
Expand Down
2 changes: 1 addition & 1 deletion roman.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'roman'
s.version = '0.3.0'
s.version = '0.3.1'
s.summary = 'Real Roman Numerals'
s.description = 'RomanNumeral class for working with roman numerals in a native form.'

Expand Down
12 changes: 12 additions & 0 deletions test/roman_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,17 @@
end
end

Method :to_s do
test "negative numbers" do
(-1).to_roman.to_s.assert == '-I'
(-4).to_roman.to_s.assert == '-IV'
(-1994).to_roman.to_s.assert == '-MCMXCIV'
end

test "a result below zero" do
(4.to_roman - 10).to_s.assert == '-VI'
end
end

end

Loading