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

キヨシ

More than 3 years have passed since last update.

時期を逃してるし、短くも気持ち悪い書き方もできないはちよんは、疲れからか不幸にも黒塗りの高級車に追突してしまう…

kiyoshi.rb
module Kiyoshi
  class Phrase
    attr_accessor :words, :pattern, :finish

    def initialize
      yield(self)
    end

    def sing
      string = ''
      string << words.sample.tap(&:display) until string =~ pattern
      puts finish
    end
  end

  class << self
    def sing(&config)
      phrase = Phrase.new(&config)
      phrase.sing
    end
  end
end
app.rb
require_relative 'kiyoshi'

Kiyoshi.sing do |zundoko|
  zundoko.words   = %w(ズン ドコ)
  zundoko.pattern = /(?:ズン){4}ドコ/
  zundoko.finish  = 'キ・ヨ・シ!'
end

Kiyoshi.sing do |shintyoku|
  shintyoku.words   = %w(進捗 どう です か)
  shintyoku.pattern = /進捗どうですか/
  shintyoku.finish  = '?'
end

Kiyoshi.sing do |yajyu|
  yajyu.words   = %w(114 514 810 1919)
  yajyu.pattern = /1145148101919/
  yajyu.finish  = '胸にかけて胸に!'
end
$ ruby app.rb
ズンドコドコズンドコドコズンドコズンズンズンズンズンドコキ・ヨ・シ!
進捗進捗かかですか進捗か進捗進捗どう進捗かどう進捗かどうか進捗ですどうですどう進捗進捗どうどう進捗進捗進捗進捗ですどうどうですか進捗どうですか?
1919114114191911411481011481011451419191919191981081051419195145148108101145145145141145148101919胸にかけて胸に!
Why not register and get more from Qiita?
  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
No 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
ユーザーは見つかりませんでした