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: []



19
20
21
22
# File 'lib/proxies/currystache.rb', line 19

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



31
32
33
# File 'lib/proxies/currystache.rb', line 31

def inspect
  proc
end

#respond_to?(method, private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to? method, private=false
  method == :to_hash
end

#to_sObject



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

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