class Elected::Lider

Attributes

created[R]
deadline[R]
diff[R]
info[R]
resource[R]
validity[R]
value[R]

Public Class Methods

new(info, timeout) click to toggle source
# File lib/elected/lider.rb, line 10
def initialize(info, timeout)
  @info     = info
  @validity = info[:validity]
  @resource = info[:resource]
  @value    = info[:value]
  @created  = Time.now
  @deadline = created + (timeout / 1000.0).to_i
  @diff     = @deadline - @created
end

Public Instance Methods

current?() click to toggle source
# File lib/elected/lider.rb, line 20
def current?
  @deadline > Time.now
end
inspect(type = :short)
Alias for: to_s
to_s(type = :short) click to toggle source
# File lib/elected/lider.rb, line 24
def to_s(type = :short)
  case type
    when :full
      "#<#{self.class.name} " +
        "resource=#{resource.inspect} " +
        "value=#{value.inspect} " +
        "validity=#{validity.inspect} " +
        "deadline=#{deadline}" +
        ">"
    when :yaml
      to_yaml
    else
      %{#<Elected::Lider|#{resource}:#{value[0, 8]}:#{validity}>}
  end
end
Also aliased as: inspect