Sha256: e1b8c7f76f9ea70fcdb336df86fc02cfc752bbe503ce55ac25d471465a2115d5

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

class BlankSlate
  instance_methods.each { |meth| undef_method(meth) unless meth =~ /^__/ }
end

module Riot
  class Message < BlankSlate
    def initialize(*phrases)
      @chunks = []; _inspect(phrases)
    end

    def to_s; @chunks.join.strip; end

    def method_missing(meth, *phrases, &blk) push(meth.to_s.gsub('_', ' ')); _inspect(phrases); end

    def comma(str, *phrases) _concat([", ", str]); _inspect(phrases); end
    def but(*phrases); comma("but", *phrases); end
    def not(*phrases); comma("not", *phrases); end
    def push(str) _concat([" ", str]); end
  private
    def _concat(chunks) @chunks.concat(chunks); self; end
    def _inspect(phrases) phrases.each { |phrase| push(phrase.inspect) }; self; end
  end # Message
end # Riot

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riot-0.10.12.pre lib/riot/message.rb