diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-10-25 10:00:36 +1100 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-10-25 10:00:36 +1100 |
| commit | 05fda6c29f0fe4742b7ea6b237ea98f737b68b8b (patch) | |
| tree | 3fca7845fc80f0d93370d2bdadb647f3f9c65d25 /lib/nil_person.rb | |
| parent | d41d881cf8af8cb8b6cb89b87a351585ee46063c (diff) | |
Document code with YARD
Diffstat (limited to 'lib/nil_person.rb')
| -rw-r--r-- | lib/nil_person.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/nil_person.rb b/lib/nil_person.rb index 30a175f..607ae77 100644 --- a/lib/nil_person.rb +++ b/lib/nil_person.rb @@ -1,26 +1,49 @@ # frozen_string_literal: true +# NilPerson class following the NullObject pattern. +# This class represents a null object for a person, providing default +# implementations that return nil or self as appropriate. class NilPerson + # Returns the name of the NilPerson. + # + # @return [nil] Always returns nil. def name nil end + # Returns the father of the NilPerson. + # + # @return [NilPerson] Always returns self. def father self end + # Returns the mother of the NilPerson. + # + # @return [NilPerson] Always returns self. def mother self end + # Returns the gender of the NilPerson. + # + # @return [nil] Always returns nil. def gender nil end + # Checks equality with another object. + # + # @param other [Object] The object to compare with. + # @return [Boolean] True if the other object is a NilPerson, false otherwise. def ==(other) other.is_a?(NilPerson) end + # Checks equality with another object (alias for ==). + # + # @param other [Object] The object to compare with. + # @return [Boolean] True if the other object is a NilPerson, false otherwise. def eql?(other) self == other end |
