Class: Mirrors::Mirror
- Inherits:
-
Object
- Object
- Mirrors::Mirror
- Defined in:
- lib/mirrors/mirror.rb
Overview
The basic mirror
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(obj) ⇒ Mirror
constructor
A new instance of Mirror.
-
#mirrors?(other) ⇒ Boolean
The equivalent to #==/#eql? for comparison of mirrors against objects.
-
#name ⇒ Object
A generic representation of the object under observation.
-
#reflectee ⇒ Object
Accessor to the reflected object.
- #subject_id ⇒ Object
Constructor Details
#initialize(obj) ⇒ Mirror
Returns a new instance of Mirror.
4 5 6 |
# File 'lib/mirrors/mirror.rb', line 4 def initialize(obj) @subject = obj end |
Instance Method Details
#mirrors?(other) ⇒ Boolean
The equivalent to #==/#eql? for comparison of mirrors against objects
22 23 24 |
# File 'lib/mirrors/mirror.rb', line 22 def mirrors?(other) @subject == other end |
#name ⇒ Object
A generic representation of the object under observation.
13 14 15 16 17 18 19 |
# File 'lib/mirrors/mirror.rb', line 13 def name if @subject.is_a?(String) || @subject.is_a?(Symbol) @subject else @subject.inspect end end |
#reflectee ⇒ Object
Accessor to the reflected object
27 28 29 |
# File 'lib/mirrors/mirror.rb', line 27 def reflectee @subject end |
#subject_id ⇒ Object
8 9 10 |
# File 'lib/mirrors/mirror.rb', line 8 def subject_id @subject.__id__.to_s end |