Skip to content

Commit

Permalink
Formatting the code
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Oct 30, 2018
1 parent deb8b81 commit ec78b1f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/concurrent/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def fetch_or_store(key, default_value = NULL)
# @return [Object, nil] the value or nil when key was present
def put_if_absent(key, value)
computed = false
result = compute_if_absent(key) do
result = compute_if_absent(key) do
computed = true
value
end
Expand All @@ -221,15 +221,15 @@ def value?(value)
# @return [::Array<Object>] keys
def keys
arr = []
each_pair {|k, v| arr << k}
each_pair { |k, v| arr << k }
arr
end unless method_defined?(:keys)

# All values
# @return [::Array<Object>] values
def values
arr = []
each_pair {|k, v| arr << v}
each_pair { |k, v| arr << v }
arr
end unless method_defined?(:values)

Expand All @@ -239,7 +239,7 @@ def values
# @return [self]
# @!macro map.atomic_method_with_block
def each_key
each_pair {|k, v| yield k}
each_pair { |k, v| yield k }
end unless method_defined?(:each_key)

# Iterates over each value.
Expand All @@ -248,7 +248,7 @@ def each_key
# @return [self]
# @!macro map.atomic_method_with_block
def each_value
each_pair {|k, v| yield v}
each_pair { |k, v| yield v }
end unless method_defined?(:each_value)

# Iterates over each key value pair.
Expand All @@ -268,31 +268,31 @@ def each_pair
# @param [Object] value
# @return [Object, nil] key or nil when not found
def key(value)
each_pair {|k, v| return k if v == value}
each_pair { |k, v| return k if v == value }
nil
end unless method_defined?(:key)
alias_method :index, :key if RUBY_VERSION < '1.9'

# Is map empty?
# @return [true, false]
def empty?
each_pair {|k, v| return false}
each_pair { |k, v| return false }
true
end unless method_defined?(:empty?)

# The size of map.
# @return [Integer] size
def size
count = 0
each_pair {|k, v| count += 1}
each_pair { |k, v| count += 1 }
count
end unless method_defined?(:size)

# @!visibility private
def marshal_dump
raise TypeError, "can't dump hash with default proc" if @default_proc
h = {}
each_pair {|k, v| h[k] = v}
each_pair { |k, v| h[k] = v }
h
end

Expand All @@ -310,6 +310,7 @@ def inspect
end

private

def raise_fetch_no_key
raise KeyError, 'key not found'
end
Expand All @@ -320,7 +321,7 @@ def initialize_copy(other)
end

def populate_from(hash)
hash.each_pair {|k, v| self[k] = v}
hash.each_pair { |k, v| self[k] = v }
self
end

Expand Down

0 comments on commit ec78b1f

Please sign in to comment.