Sha256: b19d6127e9146b96cbdb4181f942f6c2af862d65e97612aa8a90d58805a3aa05

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true
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.1 lib/content_spinning/spinner.rb