Class: NoidsClient::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/noids_client/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rest_resource) ⇒ Pool

Returns a new instance of Pool.



8
9
10
11
# File 'lib/noids_client/pool.rb', line 8

def initialize(rest_resource)
  @noid_pool = rest_resource
  update
end

Instance Attribute Details

#ids_usedObject (readonly)

Returns the value of attribute ids_used.



6
7
8
# File 'lib/noids_client/pool.rb', line 6

def ids_used
  @ids_used
end

#last_mint_dateObject (readonly)

Returns the value of attribute last_mint_date.



6
7
8
# File 'lib/noids_client/pool.rb', line 6

def last_mint_date
  @last_mint_date
end

#max_idsObject (readonly)

Returns the value of attribute max_ids.



6
7
8
# File 'lib/noids_client/pool.rb', line 6

def max_ids
  @max_ids
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/noids_client/pool.rb', line 6

def name
  @name
end

#templateObject (readonly)

Returns the value of attribute template.



6
7
8
# File 'lib/noids_client/pool.rb', line 6

def template
  @template
end

Instance Method Details

#advance_past(this_id) ⇒ Object



33
34
35
# File 'lib/noids_client/pool.rb', line 33

def advance_past(this_id)
  decode_json(@noid_pool['advancePast'].post '', params: {id: this_id})
end

#closeObject



21
22
23
# File 'lib/noids_client/pool.rb', line 21

def close
  decode_json(@noid_pool['close'].put '')
end

#closed?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/noids_client/pool.rb', line 25

def closed?
  @is_closed
end

#mint(this_many_ids = 1) ⇒ Object



29
30
31
# File 'lib/noids_client/pool.rb', line 29

def mint(this_many_ids=1)
  JSON.parse(@noid_pool['mint'].post '', params: {n: this_many_ids})
end

#openObject



17
18
19
# File 'lib/noids_client/pool.rb', line 17

def open
  decode_json(@noid_pool['open'].put '')
end

#updateObject



13
14
15
# File 'lib/noids_client/pool.rb', line 13

def update
  decode_json(@noid_pool.get)
end