-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ed8dec
commit 9b9ea8d
Showing
8 changed files
with
50 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class HexUtils | ||
class << self | ||
# convert decimal number to hex string with "0x" prefix | ||
# | ||
# @param number [Integer] | ||
# @return [String] | ||
def to_hex(number) | ||
"0x" + number.to_s(16) | ||
end | ||
|
||
# convert hex string to decimal number | ||
# | ||
# @param str [String] hex string | ||
# @return [Integer] decimal number | ||
def to_decimal(str) | ||
str.hex | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
.rbenv-vars | ||
tmp/restart.txt | ||
tmp/caching-dev.txt | ||
app/utils/** | ||
].each { |path| Spring.watch(path) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,4 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe CitaSync::Basic, type: :model do | ||
let(:number) { 100 } | ||
let(:hex_str) { "0x64" } | ||
|
||
context "number_to_hex_str" do | ||
it 'convert decimal number to hex number string' do | ||
expect(CitaSync::Basic.number_to_hex_str(100)).to eq hex_str | ||
end | ||
end | ||
|
||
context "hex_str_to_number" do | ||
it "convert hex number string to decimal number" do | ||
expect(CitaSync::Basic.hex_str_to_number(hex_str)).to eq number | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe HexUtils do | ||
let(:number) { 100 } | ||
let(:hex_str) { "0x64" } | ||
|
||
context "to_hex" do | ||
it 'convert decimal number to hex number string' do | ||
expect(HexUtils.to_hex(100)).to eq hex_str | ||
end | ||
end | ||
|
||
context "to_decimal" do | ||
it "convert hex number string to decimal number" do | ||
expect(HexUtils.to_decimal(hex_str)).to eq number | ||
end | ||
end | ||
end |