Skip to content

Commit 28703fa

Browse files
committed
Apply feedback to align with contributing guidelines and add new snippet to transform from sc to pc
1 parent 461ae2d commit 28703fa

13 files changed

+34
-181
lines changed

snippets/ruby/array-manipulation/binary-search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def binary_search(array, target)
2626
return nil
2727
end
2828

29-
# Usage
29+
# Usage:
3030
array = [1, 3, 5, 7, 9]
3131
target = 5
3232
result = binary_search(array, target)

snippets/ruby/array-manipulation/chunk-array.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def chunk_array(array, size)
1010
array.each_slice(size).to_a
1111
end
1212

13-
# Example usage:
13+
# Usage:
1414
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
1515
chunked_arr = chunk_array(arr, 2)
1616
puts chunked_arr.inspect # Output: [[1, 2], [3, 4], [5, 6], [7, 8], [9]]

snippets/ruby/array-manipulation/matrix-transpose.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def transpose_matrix(matrix)
1313
matrix.first.zip(*matrix[1..-1])
1414
end
1515

16-
# Usage
16+
# Usage:
1717
matrix = [
1818
[1, 2, 3],
1919
[4, 5, 6],

snippets/ruby/data-structures/binary-tree.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

snippets/ruby/data-structures/doubly-linked-list.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

snippets/ruby/data-structures/singly-linked-list.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

snippets/ruby/string-manipulation/capitalize-words.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def capitalize_words(str)
1010
str.split.map(&:capitalize).join(' ')
1111
end
1212

13-
# Usage
13+
# Usage:
1414
sentence = "ruby is awesome"
1515
puts capitalize_words(sentence) # Output: "Ruby Is Awesome"
1616
```

snippets/ruby/string-manipulation/count-word-occurrences-in-string.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def count_word_occurrences(text)
1313
occurrences
1414
end
1515

16-
# Usage
16+
# Usage:
1717
text = "ruby is awesome and Ruby is fun"
1818
puts count_word_occurrences(text) # Output: {"ruby"=>2, "is"=>2, "awesome"=>1, "and"=>1, "fun"=>1}
1919
```

snippets/ruby/string-manipulation/remove-punctuation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def remove_punctuation(str)
1010
str.gsub(/[[:punct:]]/, '')
1111
end
1212

13-
# Usage
13+
# Usage:
1414
text = "Hello, Ruby! How's it going?"
1515
puts remove_punctuation(text) # Output: "Hello Ruby Hows it going"
1616
```
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
title: Transform Camel Case to Snake Case
3-
description: Converts a Camel Case string to Snake case.
3+
description: Converts a Camel or Pascal Case string to Snake case.
44
author: ACR1209
5-
tags: string,convert,camel-case,snake-case
5+
tags: string,convert,camel-case,snake-case,pascal-case
66
---
77

88
```rb
99
def camel_to_snake(str)
10-
str.gsub(/([A-Z])/, '_\1').downcase
10+
str.gsub(/([A-Z])/, '_\1').sub(/^_/, '').downcase
1111
end
1212

13-
# Usage
13+
# Usage:
1414
camel_case = "camelCaseToSnakeCase"
15+
pascal_case = "PascalCaseToSnakeCase"
1516
puts camel_to_snake(camel_case) # Output: "camel_case_to_snake_case"
17+
puts camel_to_snake(pascal_case) # Output: "pascal_case_to_snake_case"
1618
```

0 commit comments

Comments
 (0)