LoginSignup
0
0

More than 5 years have passed since last update.

突然の死文字列を生成してクリップボードに追加する

Posted at
# coding: UTF-8

def sudden_death_generator(_str)
    # 文字列長を生成する。length では半角・全角が1字になるのでバイト長で判断する
    length_multibyte_strings = (_str.bytesize / 2) + 1 # +1は文字の前後の空白分

    # 文字列を生成する
    sudden_death_str = <<EOS
_#{"人" * length_multibyte_strings}_
> #{_str} <
 ̄#{"Y^" * (length_multibyte_strings - 1)}Y ̄
EOS

    # 突然の死を表示
    puts sudden_death_str
    # 突然の死をクリップボードにコピー(Mac)
    system "echo \"#{sudden_death_str.chomp}\" | pbcopy "
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0