Module: Pry::Memory::Strategy

Extended by:
Strategy
Included in:
Strategy
Defined in:
lib/pry/memory/strategy.rb

Overview

Class responsible for generating

variable names

Examples:

Pry::Memory::Strategy.variable_name
# => 'a'
Pry::Memory::Strategy.next!
Pry::Memory::Strategy.variable_name
# => 'b'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#strategyObject (readonly)

Returns the value of attribute strategy.



24
25
26
# File 'lib/pry/memory/strategy.rb', line 24

def strategy
  @strategy
end

Instance Method Details

#configure(strategy, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/pry/memory/strategy.rb', line 14

def configure(strategy, &block)
  @strategy = if strategy
    Pry::Memory::Generators::PREDEFINED[strategy]
  elsif block_given?
    Pry::Memory::Generators.new(&block)
  else
    raise "Strategy must be specified using Symbol or block"
  end
end

#next!Object



29
30
31
# File 'lib/pry/memory/strategy.rb', line 29

def next!
  strategy.next!
end

#variable_nameObject



25
26
27
# File 'lib/pry/memory/strategy.rb', line 25

def variable_name
  strategy.generate
end