@anonymous/

MonumentalStylishOlingo

Ruby

No description

fork
loading
Files
  • main.rb

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8972644737642781","path":"main.rb","file":{"path":"main.rb","content":{"asEncoding":{"base64":"bW9kdWxlIEJsYWNrTWFnaWMKICBkZWYgc2VsZi5pbmNsdWRlZChrbGFzcykKICAgIGtsYXNzLmV4dGVuZChNZXRob2RBY2Nlc3Nvck1hY3JvcykKICBlbmQKICAKICBtb2R1bGUgTWV0aG9kQWNjZXNzb3JNYWNyb3MKICAgIGRlZiBtZXRob2RfYWNjZXNzb3IobWV0aG9kX25hbWUpCiAgICAgIHNlbGYuY2xhc3MuaW5zdGFuY2VfZXZhbCBkbwogICAgICAgIEFycmF5KG1ldGhvZF9uYW1lKS5lYWNoIGRvCiAgICAgICAgICBkZWZpbmVfbWV0aG9kKCIje21ldGhvZF9uYW1lfV9mbiIuaW50ZXJuKSBkbwogICAgICAgICAgICBtZXRob2QobWV0aG9kX25hbWUuaW50ZXJuKQogICAgICAgICAgZW5kCiAgICAgICAgZW5kCiAgICAgIGVuZAogICAgZW5kCiAgZW5kCmVuZAoKbW9kdWxlIEZvbwogIGluY2x1ZGUgQmxhY2tNYWdpYwoKICBtZXRob2RfYWNjZXNzb3IgOmJhcgoKICBkZWYgc2VsZi5iYXIoeCkKICAgIGlmIHggPT0gImxvcmVtIgogICAgICAiYmFyIgogICAgZWxzZQogICAgICAiYmF6IgogICAgZW5kCiAgZW5kCmVuZAoKeHMgPSBbImxvcmVtIiwgImlwc3VtIiwgImRvbG9yIl0KCnhzLm1hcCgmRm9vOjpiYXJfZm4p"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module BlackMagic
  def self.included(klass)
    klass.extend(MethodAccessorMacros)
  end
  
  module MethodAccessorMacros
    def method_accessor(method_name)
      self.class.instance_eval do
        Array(method_name).each do
          define_method("#{method_name}_fn".intern) do
            method(method_name.intern)
          end
        end
      end
    end
  end
end

module Foo
  include BlackMagic

  method_accessor :bar

  def self.bar(x)
    if x == "lorem"
      "bar"
    else
      "baz"
    end
  end
end

xs = ["lorem", "ipsum", "dolor"]

xs.map(&Foo::bar_fn)
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]