[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:106159] [Ruby master Feature#6733] New inspect framework
From:
"kou (Kouhei Sutou)" <noreply@...>
Date:
2021-11-18 21:07:01 UTC
List:
ruby-core #106159
Issue #6733 has been updated by kou (Kouhei Sutou).
This may be out-of-scope but I hope that this mechanism also supports multimedia like Julia: https://docs.julialang.org/en/v1/base/io-network/#Multimedia-I/O
My use case is showing images on irb automatically.
For example with [Red Datasets](https://github.com/red-data-tools/red-datasets) and [Charty](https://github.com/red-data-tools/charty/):
```text
irb(main):001:0> require "datasets"
=> true
irb(main):002:0> require "charty"
=> true
irb(main):003:0> penguins = Datasets::Penguins.new
=>
#<Datasets::Penguins:0x00007f308dd34d10
...
irb(main):004:0> Charty.scatter_plot(data: penguins, x: :body_mass_g, y: :flipper_length_mm, color: :species)
=> #<Charty::Plotters::ScatterPlotter:0x0000000000000424> # Show Sixel images here if the terminal supports Sixel
```
ref: [Sixel](https://en.wikipedia.org/wiki/Sixel)
----------------------------------------
Feature #6733: New inspect framework
https://bugs.ruby-lang.org/issues/6733#change-94761
* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
----------------------------------------
After we discussed http://bugs.ruby-lang.org/issues/6291 at a developer meeting,
we re-realized new inspect framework may be useful.
Problem:
* inspect method may generate too long string but sometimes whole string is not required.
For example, first 70 characters are enough for error messages (backtrace).
* inspect can't know a encoding to be expected.
* inspect generates may short strings and discard them immediately.
If we have a new method, inspect_to(buffer), and
it (or overridden method in subclass) adds the inspected result to buffer,
we can solve above problems.
buffer has a method, <<.
It may be a string, IO or other object.
For too long string, buffer itself can throw (or raise) when buffered output is reached to a specified limit.
For encoding, buffer can record an encoding.
(p method creates a buffer object using $stdout's encoding.)
For small strings, in C level, we can create a rb_buffer_add(VALUE buffer, const char *p, long len) and
it don't need to allocate a String object.
This is big change but we can preserve compatibility by following default inspect_to method:
class Object
def inspect_to(buffer)
buffer << self.inspect
end
end
If legacy class which has inspect but not inspect_to,
Object#inspect_to calls inspect and use the result.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>