Sha256: edddc0797d71b8d2021550223dd229b8d0ad9d03c7258905aea88a7b5d10b9f9

Contents?: true

Size: 639 Bytes

Versions: 40

Compression:

Stored size: 639 Bytes

Contents

class Hash

  # Traverses the Hash for a given +path+ of Hash keys and returns
  # the value as an Array. Defaults to return an empty Array in case the path does not
  # exist or returns nil.
  # Copied from Savon::SOAP::Response#to_array
  def to_array(*path)
    result = path.inject(self) do |memo, key|
      return [] unless memo[key]
      memo[key]
    end

    [result].compact.flatten(1)
  end

end

class TrueClass
  def y_or_n
    'y'
  end
end

class FalseClass
  def y_or_n
    'n'
  end
end

class String
  def y_or_n
    raise ArgumentError.new 'Expecting y or n' unless ['y', 'n'].include? self.downcase
    self
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ratis-3.6.6 lib/ratis/core_ext.rb
ratis-3.6.5 lib/ratis/core_ext.rb
ratis-3.6.4 lib/ratis/core_ext.rb
ratis-3.6.3 lib/ratis/core_ext.rb
ratis-3.6.2 lib/ratis/core_ext.rb
ratis-3.6.1 lib/ratis/core_ext.rb
ratis-3.6.0 lib/ratis/core_ext.rb
ratis-3.5.0 lib/ratis/core_ext.rb
ratis-3.4.3 lib/ratis/core_ext.rb
ratis-3.4.2 lib/ratis/core_ext.rb
ratis-3.4.1 lib/ratis/core_ext.rb
ratis-3.4.0 lib/ratis/core_ext.rb
ratis-3.3.7 lib/ratis/core_ext.rb
ratis-3.3.6 lib/ratis/core_ext.rb
ratis-3.3.5 lib/ratis/core_ext.rb
ratis-3.3.4 lib/ratis/core_ext.rb
ratis-3.3.3 lib/ratis/core_ext.rb
ratis-3.3.2 lib/ratis/core_ext.rb
ratis-3.3.1 lib/ratis/core_ext.rb
ratis-3.3.0 lib/ratis/core_ext.rb