primus_lapus 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: fbabbc361b1b74da99d147daa13ce95ba84170b0
4
- data.tar.gz: a9d4fcd4c74f7af48577294cd2a6fa5e483798e0
3
+ metadata.gz: 6e7f9ceded7eaf6b64c2636f156ff335c9be713e
4
+ data.tar.gz: c674854b6e024c9ce5f810a7b849da03d07324cd
5
5
  SHA512:
6
- metadata.gz: 631467cf5af610cafa9f1b46e8504bcb91dc36397dc3c800ae43116daa719107f3e3d91046e6221faed6817de21d19ca0864cdb8ddffd29957b0e0ba6ba01b8f
7
- data.tar.gz: 579b2dd77a818756be9287c355b8c01bfd6d58c0264b2ee77783061a8ce7bd21a03b4a62049dabee5cb95ae79a0f60a1b70d60b1327b82c3e8f09638f4cf3110
6
+ metadata.gz: e57011024515209b68012aa493e2b232945ab160c6bc1051f5e9f0e988a09551b91523dc28b43cd101d0aade71208eb46085c4f7f3aa81e6bc902f72082f46e9
7
+ data.tar.gz: 78d6c9647c0ec1a5685ca81617de07f12aa6c010668c508a3caf897d56adbc17233e84408e94de043808db6f277f27661951c4dd6b7f187062f5262a4f97cadd
@@ -1,3 +1,3 @@
1
1
  module Primus
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/primus.rb CHANGED
@@ -1,40 +1,15 @@
1
- require "primus/version"
1
+ # frozen_string_literal: true
2
2
 
3
- module Primus
4
- class Reorder
5
- def call(hash)
6
- is_hash_empty?(hash)
7
- sort_array
8
- convert_to_upcase_string
9
- end
10
-
11
- private
12
-
13
- def is_hash_empty?(hash)
14
- raise RuntimeError.new("This hash is empty") if hash.empty?
15
- take_odd_keys(hash)
16
- end
17
-
18
- def take_odd_keys(hash)
19
- hash.each_with_index { |(key,value), index| array << key if index.odd? }
20
- end
21
-
22
- def sort_array
23
- array.sort! { |x,y| y <=> x }
24
- end
25
-
26
- def convert_to_upcase_string
27
- array.each { |c| string << c.upcase }
28
- string
29
- end
30
-
31
- def array
32
- @array ||= []
33
- end
34
-
35
- def string
36
- @string ||= ""
37
- end
3
+ require 'primus/version'
38
4
 
5
+ # Takes a hash and returns string of reverse order odd keys
6
+ class Primus
7
+ def self.call(hash)
8
+ raise 'This hash is empty' if hash.empty?
9
+ array = hash.each_with_index.map { |(key), index| key.upcase if index.odd? }.compact
10
+ array.sort.reverse.join('')
39
11
  end
40
12
  end
13
+
14
+ # add rubo cop, frozen string, revise sort each with index, each_slice,
15
+ # slice_each, call this without caiing .new
data/no_new.rb ADDED
@@ -0,0 +1,7 @@
1
+ require './lib/primus'
2
+
3
+ include Primus
4
+
5
+ hash = { 'a' => 1, 'b' => 2, 'c' => 3 }
6
+
7
+ puts call(hash)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primus_lapus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Page
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,6 +114,7 @@ files:
114
114
  - bin/setup
115
115
  - lib/primus.rb
116
116
  - lib/primus/version.rb
117
+ - no_new.rb
117
118
  - primus.gemspec
118
119
  homepage:
119
120
  licenses: