Sha256: 84e94a0b454fc47c37d82689984397dc3c842d16203c2bd713a18b76bd2b4a8a
Contents?: true
Size: 675 Bytes
Versions: 1
Compression:
Stored size: 675 Bytes
Contents
require "primus/version" module Primus class Reorder def call(hash) is_hash_empty?(hash) sort_array convert_to_upcase_string end private def is_hash_empty?(hash) raise RuntimeError.new("This hash is empty") if hash.empty? take_odd_keys(hash) end def take_odd_keys(hash) hash.each_with_index { |(key,value), index| array << key if index.odd? } end def sort_array array.sort! { |x,y| y <=> x } end def convert_to_upcase_string array.each { |c| string << c.upcase } string end def array @array ||= [] end def string @string ||= "" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
primus_lapus-0.1.1 | lib/primus.rb |