Class: Proxies::Currystache

Inherits:
Object
  • Object
show all
Defined in:
lib/proxies/currystache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(my_proc) ⇒ Currystache

Returns a new instance of Currystache.



6
7
8
9
# File 'lib/proxies/currystache.rb', line 6

def initialize my_proc
  @proc     = my_proc
  @args     = []
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/proxies/currystache.rb', line 4

def args
  @args
end

#procObject (readonly)

Returns the value of attribute proc.



4
5
6
# File 'lib/proxies/currystache.rb', line 4

def proc
  @proc
end

Instance Method Details

#call(arg) ⇒ Object Also known as: []



15
16
17
18
# File 'lib/proxies/currystache.rb', line 15

def call arg
  args << arg
  self
end

#has_key?(arg) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/proxies/currystache.rb', line 11

def has_key? arg
  true
end

#inspectObject



27
28
29
# File 'lib/proxies/currystache.rb', line 27

def inspect
  proc
end

#to_sObject



21
22
23
24
25
# File 'lib/proxies/currystache.rb', line 21

def to_s
  result = proc.call(*args)
  args.clear
  result.to_s
end