Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.
# 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
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away