Sha256: 27722c0f9d0dbd03b7a0455cf8980765d9676be5e970c19d1410f5e957fa60c0

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

require_relative "./commands"

module Pinoccio
  class Troop
    include Commands

    attr_reader :account, :id, :online, :name

    def initialize(client, props)
      @client = client
      @account = props.account
      @id = props.id
      @online = props.online
      @name = props.name
    end

    def scouts
      ScoutCollection.new(@client, self)
    end

    def run(command, type=nil)
      collect_across_all { |scout| scout.run(command, type) }
    end

    def get(command, type=nil)
      collect_across_all { |scout| scout.get(command, type) }
    end

    def execute(command)
      collect_across_all { |scout| scout.execute(command) }
    end

    private
    def collect_across_all(&blk)
      scouts.all.reduce({}) do |hsh, scout|
        hsh[scout.id] = yield(scout)
        hsh
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pinoccio-0.1.0 lib/troop.rb