Sha256: a6ce92deec5156b44f83d60eabf2e53120b330bcca55f26d33a2548664fbb011

Contents?: true

Size: 530 Bytes

Versions: 1

Compression:

Stored size: 530 Bytes

Contents

class ContentSpinning

  class Spinner < ::Array

    def initialize(*items)
      push(*items)
    end

    def cleaned
      map!(&:cleaned)

      uniq!

      if length == 1
        first
      else
        self
      end
    end

    def count
      map(&:count).inject(:+)
    end

    def inspect
      "<Spinner {#{map(&:inspect).join(" | ")}}>"
    end

    def random
      sample.random
    end

    def spin
      flat_map(&:spin)
    end

    def to_source
      "{#{map(&:to_source).join("|")}}"
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
content_spinning-0.3.0 lib/content_spinning/spinner.rb