Sha256: bd81a28bb368f5f7d0d6880d40d0d6544def3707dd8270601ccb6852d3e12f62

Contents?: true

Size: 624 Bytes

Versions: 2

Compression:

Stored size: 624 Bytes

Contents

class Hadouken::Group
  attr_reader :name
  attr_reader :range
  attr_reader :pattern

  def initialize(opts)
    @name    = opts[:name]
    @range   = opts[:range]
    @pattern = opts[:pattern]
  end

  def count
    @count ||= hosts.size
  end
  alias :size :count

  def hosts
    @hosts ||= @range.map{|idx| "#{@pattern}" % [ idx ] }.map do |hostname|
      Hadouken::Hosts.add({:name => hostname})
    end
  end

  def has_host?(name)
    @hosts_by_name ||= hosts.inject({}){|h,host| h[host]=true; h}
    @hosts_by_name.has_key?(name)
  end

  def self.create!(name, opts)
    new(opts.merge(:name => name))
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hadouken-0.1.5.pre lib/hadouken/group.rb
hadouken-0.1.4.pre lib/hadouken/group.rb