Class: TestMemoize::Encoder

Inherits:
Object
  • Object
show all
Includes:
Rip::Memoize
Defined in:
lib/rip/memoize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rip::Memoize

included, #memoize, #method_added

Constructor Details

#initializeEncoder

Returns a new instance of Encoder.



52
53
54
# File 'lib/rip/memoize.rb', line 52

def initialize
  @encodes = 0
end

Instance Attribute Details

#encodesObject (readonly)

Returns the value of attribute encodes.



51
52
53
# File 'lib/rip/memoize.rb', line 51

def encodes
  @encodes
end

Instance Method Details

#encode(name) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/rip/memoize.rb', line 57

def encode(name)
  @encodes += 1

  parts = name.split(//).map do |letter|
    letter[0]
  end

  parts.join('/')
end

#simpleObject



68
69
70
71
# File 'lib/rip/memoize.rb', line 68

def simple
  @encodes += 1
  1 + 1
end