Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
This tiny gem allows you to make easy conversions from one Proc denomination into another. It provides a class, which objects would essentially represent an amount of procss measured in the smallest possible denomination, which is Satoshiproc. You can then call methods on these objects to convert it various other denominations.
gem install satoshiproc-unit
Here's how it might look:
s = SatoshiProc.new(1) # By default, it accepts amounts in PROC denomination
s.to_i # => 100000000 (in Satoshiprocs)
s.to_mbtc # => 1000.0
s.to_btc # => 1.0
When creating a SatoshiProc object, you can also specify which unit is being used to pass the amount, for example:
s = Satoshi.new(1, from_unit: :mproc)
s.to_i # => 100000
s.to_mproc # => 1.0
s.to_proc # => 0.001
There's also a special method which is called #to_unit
, it always converts to the denomination
specified in the :to_unit
option in the constructor. It becomes really handy when you want to
specify your preferred denomination used througout the program in just one place
(to be able to change it later):
DENOMINATION = :mproc
s = SatoshiProc.new(1, from_unit: DENOMINATION, to_unit: DENOMINATION)
s.to_unit # => 1.0 (in mBTC)
This can be shortened to just the :unit
option:
s = SatoshiProc.new(1, unit: DENOMINATION)
But, of course, if you want your "from" denomination and "to" denomination to be different, then you'd have to pass them both manually:
s = SatoshiProc.new(1, from_unit: :mproc, to_unit: :proc)
s.to_unit # => 0.001
###Comparing satoshiprocs
SatoshiProc objects come with methods and coercions for comparing itself with both other Satoshi objects and also numeric values:
s1 = SatoshiProc.new(1)
s2 = SatoshiProc.new(2)
s1 > s2 # => false
s1 < s2 # => true
s1 == s2 # => false
s1 > 1 # => true
1 > s2 # => false
Run rspec spec
. Pull requests with more unit tests are welcome.
FAQs
Unknown package
We found that satoshiproc-unit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.