class Hash

Public Instance Methods

apricot_call(key, default = nil) click to toggle source
# File lib/apricot/ruby_ext.rb, line 105
def apricot_call(key, default = nil)
  fetch(key, default)
end
apricot_inspect() click to toggle source

Adapted from Hash#inspect. Outputs Apricot hash syntax, e.g. {:a 1, :b 2}

# File lib/apricot/ruby_ext.rb, line 87
def apricot_inspect
  return '{}' if size == 0

  str = '{'

  return '{...}' if Thread.detect_recursion self do
    each_item do |item|
      str << item.key.apricot_inspect
      str << ' '
      str << item.value.apricot_inspect
      str << ', '
    end
  end

  str.shorten!(2)
  str << '}'
end
Also aliased as: apricot_str
apricot_str()
Alias for: apricot_inspect
to_seq() click to toggle source
# File lib/apricot/ruby_ext.rb, line 111
def to_seq
  each_pair.to_a.to_seq
end