matheus 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e859fa5b5a161ef7c0d97e5519a99a54337a19706b50144f2ac86792694067a1
4
- data.tar.gz: e03c984893f614ef40b84197e6d6016cee38ed6ca306b89a1057885ea040e76e
3
+ metadata.gz: f8b7ae705faac28863e66c70a5c908c53a2fe180aa14c0878aef57ae82ca8421
4
+ data.tar.gz: e89436cbe02bbc48261114ff617a39d42f52f0d2aae1b178ddd55036ace7d92d
5
5
  SHA512:
6
- metadata.gz: 79ae596c0b3363e865a3bd664ae7a174ba231d6cec6c41bb29358402e145e9ad4dee6ed6ee7b96fb95420f935b2377f4ae81c0445f92188f3d77a54fd31d9d80
7
- data.tar.gz: 7cffe1c0d148e3f4310e6876f649ba7dd7e8767eb792132f211c0f6b164b7928e625f2b58577299eaba363358962a8363a3ea991cf24aecd59714d831d9d0471
6
+ metadata.gz: d8dd9bbb999502ef1689a75115844a32eaa131b92e41c665f00f9d9337e1d9a80669ad1c475ca5ddcb1313c4bfdd53bcfe31763a99b823a00bac96e4de46a49a
7
+ data.tar.gz: fe9f27e3980c294dbb6e06b17f9f66c214432fceae199725caf33de20e1998037d2716266238465c90567996ddae14fd88820c7f2e90672b442120af92a0000d
@@ -8,6 +8,8 @@ module Matheus
8
8
  # $ convert-currency 100 usd eur 2024-03-06
9
9
  # $ convert-currency usd eur # defaults to 1
10
10
  class ConvertCurrency < Command
11
+ include ActiveSupport::NumberHelper
12
+
11
13
  def call(args)
12
14
  amount, source, target, date = parse_args(args)
13
15
 
@@ -17,7 +19,7 @@ module Matheus
17
19
 
18
20
  if rate
19
21
  converted = amount * rate
20
- puts "#{amount} #{source.upcase} = #{ActiveSupport::NumberHelper.number_to_currency(converted, unit: "")} #{target.upcase}"
22
+ puts "#{number_to_currency(amount, unit: "")} #{source.upcase} = #{number_to_currency(converted, unit: "")} #{target.upcase}"
21
23
  else
22
24
  Failure("Conversion rate from #{source.upcase} to #{target.upcase} not found")
23
25
  end
@@ -33,12 +35,12 @@ module Matheus
33
35
  if (amount = Float(first_arg) rescue nil) # standard:disable Style/RescueModifier
34
36
  source = args.fetch(1) { raise "Missing source currency" }
35
37
  target = args.fetch(2) { raise "Missing target currency" }
36
- date = Date.parse(args.fetch(3, Date.today))
38
+ date = Date.parse(args.fetch(3, Date.today.to_s))
37
39
  else
38
40
  amount = 1.0
39
41
  source = first_arg
40
42
  target = args.fetch(1) { raise "Missing target currency" }
41
- date = Date.parse(args.fetch(2, Date.today))
43
+ date = Date.parse(args.fetch(2, Date.today.to_s))
42
44
  end
43
45
 
44
46
  [amount, source, target, date]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Matheus
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Richard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-16 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk