Class: Fixnum
- Inherits:
-
Object
- Object
- Fixnum
- Defined in:
- lib/1_as_identity_function.rb
Instance Method Summary collapse
- #respond_to_with_1_as_identity_function?(name, include_private = false) ⇒ Boolean (also: #respond_to?)
- #to_proc ⇒ Object
Instance Method Details
#respond_to_with_1_as_identity_function?(name, include_private = false) ⇒ Boolean Also known as: respond_to?
8 9 10 11 12 13 14 |
# File 'lib/1_as_identity_function.rb', line 8 def respond_to_with_1_as_identity_function?(name, include_private = false) if name.to_s == 'to_proc' return self == 1 else return respond_to_without_1_as_identity_function?(name, include_private) end end |
#to_proc ⇒ Object
4 5 6 7 |
# File 'lib/1_as_identity_function.rb', line 4 def to_proc raise NoMethodError unless self == 1 lambda {|x| x} end |