Sha256: 53f9d3d741dd9b369ad021e6aa3d935d5095e7da013c9837a105262ad39ccf42

Contents?: true

Size: 747 Bytes

Versions: 2

Compression:

Stored size: 747 Bytes

Contents

module GithubCLI
  module Util
    extend self

    def flatten_hash(prefix=nil, hash, new_hash)
      hash.each do |key, val|
        key =  prefix ? :"#{prefix}_#{key}" : key
        case val
        when Hash
          flatten_hash(key, val, new_hash)
        else
          new_hash[key] = val
        end
      end
      return new_hash
    end

    def convert_values(values)
      values_copy = values.dup
      collected = []
      values_copy.inject([]) do |collected, val|
        collected << case val
          when true
            "true"
          when false
            "false"
          when Hash
            self.convert_values(val.values)
          else
            val.to_s
          end
      end
    end
  end
end # GithubCLI

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
github_cli-0.3.1 lib/github_cli/util.rb
github_cli-0.3.0 lib/github_cli/util.rb