lightning-invoice 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da417a5937a2c557525216152eaa8c781a61149e9a3570bebf025d9b39f8cc05
4
- data.tar.gz: 2e06f5a1c4ce90876e538cd37d630e872c5954c7f82f6df172513b97e3fd7c66
3
+ metadata.gz: 7d9ee675efd28bb1aaa0419de6305b000fc0f9ac24f6e5b53af91c95f541f0e9
4
+ data.tar.gz: b714ce6c8d41d34854aacd30f2954a13aeb83871a335336899f49029545df850
5
5
  SHA512:
6
- metadata.gz: 6bdfd0640908019f31e1ecbd1b30eea3ba26f5f93787b924a61a94671de9888ce547dd48e2e1684ffe498cea18b8be6e375eabcf0adbab667338660c455067a1
7
- data.tar.gz: 9266c30da04a5dc4d9cdcf4b79cdc744e7c3c7f87497bde42287035127cf2e8407653bb3f9135849100dbad9a11171e389f1e302f354d43f1d2dce669ee8d9b9
6
+ metadata.gz: 36a04d62fb52bc2efd3069054f026d32b55b6fe453bd7c3d20f5ed4e563b6a57872a7825ffce081b0beab1bae36cfc721f6bfb6b07c0f050fdcd303b68bb0844
7
+ data.tar.gz: 84b1a06fc319b39433948ce8b2d1c960034006cfd3a055f8203511c68815524c44abca69a73f37fc928759c9439fac8aadfbbb36ef1cffde68203bbec7388075
@@ -174,6 +174,24 @@ module Lightning
174
174
  message
175
175
  end
176
176
 
177
+ def self.msat_to_readable(msat)
178
+ if msat >= 100_000_000_000
179
+ [(msat / 100_000_000_000).to_i, '']
180
+ elsif msat >= 100_000_000
181
+ [(msat / 100_000_000).to_i, 'm']
182
+ elsif msat >= 100_000
183
+ [(msat / 100_000).to_i, 'u']
184
+ elsif msat >= 100
185
+ [(msat / 100).to_i, 'n']
186
+ elsif msat > 0
187
+ [(msat * 10).to_i, 'p']
188
+ elsif msat == 0
189
+ [0, '']
190
+ else
191
+ raise 'amount_msat should be greater than or equal to 0'
192
+ end
193
+ end
194
+
177
195
  def self.parse_human_readable(human)
178
196
  human.scan(/^([a-zA-Z]+)(\d*)([munp]?)$/)&.first
179
197
  end
@@ -1,5 +1,5 @@
1
1
  module Lightning
2
2
  module Invoice
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightning-invoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hajime Yamaguchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-22 00:00:00.000000000 Z
11
+ date: 2018-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler