Skip to content

improve Kredis::Types::List #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

improve Kredis::Types::List #151

wants to merge 5 commits into from

Conversation

balbesina
Copy link

Several List improvements.

  • allow to pass range to List#elements.
  • add List#size and List#first.
  • fix List#last to return typed.

Mikhail Varabyou added 2 commits March 31, 2024 11:09
allow to pass range to List#elements.
fix List#last to return typed.
@balbesina
Copy link
Author

any chance someone can review it?


attr_accessor :typed

def elements
strings_to_types(lrange(0, -1) || [], typed)
def elements(start = 0, stop = -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than give slicing arguments to #elements, would introduce #slice and have #elements call it.

@list.append [ 1.day.from_now.midnight.in_time_zone("Pacific Time (US & Canada)"), 2.days.from_now.midnight.in_time_zone("UTC") ]
assert_equal [ 1.day.from_now.midnight, 2.days.from_now.midnight ], @list.elements
test "size" do
@list.clear
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would assert_equal 0, @list.size here rather than having a separate test for size after removal.

@balbesina balbesina requested a review from jeremy April 19, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants