Skip to content

Instantly share code, notes, and snippets.

@xmisao
xmisao / define_keyword_arugments_method.rb
Created August 6, 2017 04:20
動的にキーワード引数のメソッドを定義するメソッド
def define_keyword_arguments_method(method_name, *keywords)
instance_eval <<RUBY
define_method(:#{method_name}){|#{keywords.map{|kw| kw + ':'}.join(', ')}|
yield #{keywords.map{|kw| "#{kw}: #{kw}"}.join(', ')}
}
RUBY
end
define_keyword_arguments_method(:my_method, 'arg1', 'arg2', 'arg3') do |**kwargs|
p kwargs
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Add-Content 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Add-History 3.0.0.0 Microsoft.PowerShell.Core
Cmdlet Add-Member 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Add-Type 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Clear-Content 3.
#include<X11/Xlib.h>
#include<stdio.h>
#include<time.h>
typedef struct{
int x, y;
} Pos;
Pos get_pos(Display *dpy, Window root){
Window w;