Sha256: ec03edf82ac5b9f4434518bae5999bf142898567e3eeb5f312962d16d529aebc

Contents?: true

Size: 768 Bytes

Versions: 12

Compression:

Stored size: 768 Bytes

Contents

class BlankSlate
  instance_methods.each { |meth| undef_method(meth) unless meth.to_s =~ /^(__|object_id)/ }
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

12 entries across 12 versions & 1 rubygems

Version Path
riot-0.12.1 lib/riot/message.rb
riot-0.12.0 lib/riot/message.rb
riot-0.12.0.pre lib/riot/message.rb
riot-0.11.4 lib/riot/message.rb
riot-0.11.4.pre lib/riot/message.rb
riot-0.11.3 lib/riot/message.rb
riot-0.11.2 lib/riot/message.rb
riot-0.11.1 lib/riot/message.rb
riot-0.11.0 lib/riot/message.rb
riot-0.10.13 lib/riot/message.rb
riot-0.10.13.pre lib/riot/message.rb
riot-0.10.12 lib/riot/message.rb