Skip to content

Commit

Permalink
docs: consistent YARD type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
eliias committed Feb 8, 2023
1 parent 6b8b630 commit 852f785
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions lib/y/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ def initialize(doc = nil)

# Retrieves element at position
#
# @return [true|false|Float|Integer|String|Array|Hash]
# @return [true, false, Float, Integer, String, Array, Hash]
def [](index)
document.current_transaction { |tx| yarray_get(tx, index) }
end

# Inserts value at position
#
# @param index [Integer]
# @param value [true|false|Float|Integer|String|Array|Hash]
# @param value [true, false, Float, Integer, String, Array, Hash]
# @return [void]
def []=(index, value)
document.current_transaction { |tx| yarray_insert(tx, index, value) }
end

# Adds an element to the end of the array
#
# @param value [true|false|Float|Integer|String|::Array|Hash]
# @param value [true, false, Float, Integer, String, ::Array, Hash]
# @return [void]
def <<(value, *values)
document.current_transaction do |tx|
Expand Down Expand Up @@ -121,21 +121,21 @@ def each(&block)

# Check if the array is empty
#
# @return [true|false]
# @return [true, false]
def empty?
size.zero?
end

# Returns first element in array if there is at least one
#
# @return [true|false|Float|Integer|String|::Array|Hash|nil]
# @return [true, false, Float, Integer, String, ::Array, Hash, nil]
def first
document.current_transaction { |tx| yarray_get(tx, 0) }
end

# Returns last element in array if there is at least one element
#
# @return [true|false|Float|Integer|String|::Array|Hash|nil]
# @return [true, false, Float, Integer, String, ::Array, Hash, nil]
def last
document.current_transaction do |tx|
len = yarray_length(tx)
Expand All @@ -149,7 +149,7 @@ def last

# Removes last (n) element(s) from array
#
# @param n [Integer|nil] Number of elements to remove
# @param n [Integer, nil] Number of elements to remove
# @return [void]
def pop(n = nil)
document.current_transaction do |tx|
Expand All @@ -167,7 +167,7 @@ def pop(n = nil)

# Removes first (n) element(s) from array
#
# @param n [Integer|nil] Number of elements to remove
# @param n [Integer, nil] Number of elements to remove
# @return [void]
def shift(n = nil)
document.current_transaction do |tx|
Expand Down Expand Up @@ -264,7 +264,7 @@ def slice!(*args)

# Convert this array to a Ruby Array
#
# @return [Array<true|false|Float|Integer|String|::Array|Hash>]
# @return [Array<true, false, Float, Integer, String, ::Array, Hash>]
def to_a
document.current_transaction { |tx| yarray_to_a(tx) }
end
Expand Down Expand Up @@ -306,7 +306,7 @@ def unshift(value)
#
# @param transaction [Y::Transaction]
# @param index [Integer]
# @param arr [Array<Boolean|Float|Integer|Array|Hash|Text>]
# @param arr [Array<Boolean, Float, Integer, Array, Hash, Text>]
# @return [void]
# @!visibility private

Expand Down
4 changes: 2 additions & 2 deletions lib/y/awareness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def diff_with_clients(*clients)

# @!method yawareness_local_state
#
# @return [String|nil] Returns a JSON string state representation of a
# @return [String, nil] Returns a JSON string state representation of a
# current Awareness instance.
# @!visibility private

Expand All @@ -234,7 +234,7 @@ def diff_with_clients(*clients)
# disconnected.
#
# @param client_id [Integer] A Client ID
# @return [String|nil] Returns a JSON string state representation of a
# @return [String, nil] Returns a JSON string state representation of a
# current Awareness instance.
# @!visibility private

Expand Down
16 changes: 8 additions & 8 deletions lib/y/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def clear
# m.delete(:nosuch) { |key| "Key #{key} not found" }# => "Key nosuch not found"
# m # => {}
#
# @param key [String|Symbol]
# @param key [String, Symbol]
# @return [void]
def delete(key)
value = document.current_transaction { |tx| ymap_remove(tx, key) }
Expand All @@ -96,7 +96,7 @@ def each(&block)
document.current_transaction { |tx| ymap_each(tx, block) }
end

# @return [true|false]
# @return [true, false]
def key?(key)
document.current_transaction { |tx| ymap_contains(tx, key) }
end
Expand Down Expand Up @@ -143,29 +143,29 @@ def to_json(*_args)
# Check if a certain key is in the Map
#
# @param tx [Y::Transaction]
# @param key [String|Symbol]
# @param key [String, Symbol]
# @return [Boolean] True, if and only if the key exists

# @!method ymap_each(tx, proc)
# Iterates over all key-value pairs in Map by calling the provided proc
# with the key and the value as arguments.
#
# @param tx [Y::Transaction]
# @param proc [Proc<String|Any>] A proc that is called for every element
# @param proc [Proc<String, Any>] A proc that is called for every element

# @!method ymap_get(tx, key)
# Returns stored value for key or nil if none is present
#
# @param tx [Y::Transaction]
# @param key [String|Symbol]
# @return [Object|nil] Value or nil
# @param key [String, Symbol]
# @return [Object, nil] Value or nil

# @!method ymap_insert(tx, key, value)
# Insert value for key. In case the key already exists, the previous value
# will be overwritten.
#
# @param tx [Y::Transaction]
# @param key [String|Symbol]
# @param key [String, Symbol]
# @param value [Object]

# @!method ymap_observe(callback)
Expand All @@ -177,7 +177,7 @@ def to_json(*_args)
# Removes key-value pair from Map if key exists.
#
# @param tx [Y::Transaction]
# @param key [String|Symbol]
# @param key [String, Symbol]

# @!method ymap_size(tx)
# Returns number of key-value pairs stored in map
Expand Down
4 changes: 2 additions & 2 deletions lib/y/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def empty?
# - Hash (where the the types of key and values must be supported)
#
# @param index [Integer]
# @param value [String|Numeric|Array|Hash]
# @param attrs [Hash|nil]
# @param value [String, Numeric, Array, Hash]
# @param attrs [Hash, nil]
# @return [void]
def insert(index, value, attrs = nil)
document.current_transaction do |tx|
Expand Down

0 comments on commit 852f785

Please sign in to comment.