Class: Proxies::Currystache
- Inherits:
-
Object
- Object
- Proxies::Currystache
- Defined in:
- lib/proxies/currystache.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
- #call(arg) ⇒ Object (also: #[])
- #has_key?(arg) ⇒ Boolean
-
#initialize(my_proc) ⇒ Currystache
constructor
A new instance of Currystache.
- #inspect ⇒ Object
- #respond_to?(method, private = false) ⇒ Boolean
- #to_s ⇒ Object
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/proxies/currystache.rb', line 4 def args @args end |
#proc ⇒ Object (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
11 12 13 |
# File 'lib/proxies/currystache.rb', line 11 def has_key? arg true end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/proxies/currystache.rb', line 31 def inspect proc end |
#respond_to?(method, private = false) ⇒ Boolean
15 16 17 |
# File 'lib/proxies/currystache.rb', line 15 def respond_to? method, private=false method == :to_hash end |
#to_s ⇒ Object
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 |