Class: YNelson::Dimension

Inherits:
Object
  • Object
show all
Defined in:
lib/y_nelson/dimension.rb

Overview

Zz dimension can in principle be any object, in YNelson, special class Dimension is used.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Dimension

Simply assigns array of arguments to @object atrribute.



29
30
31
# File 'lib/y_nelson/dimension.rb', line 29

def initialize *args
  @object = args
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



25
26
27
# File 'lib/y_nelson/dimension.rb', line 25

def object
  @object
end

Class Method Details

.__new__Object



8
# File 'lib/y_nelson/dimension.rb', line 8

alias __new__ new

.instancesObject

Presents class-owned instances (array).



12
13
14
# File 'lib/y_nelson/dimension.rb', line 12

def instances
  return @instances ||= []
end

.new(*args) ⇒ Object

The #new constructor is changed, so that same instance is returned for same constructor arguments.



19
20
21
22
# File 'lib/y_nelson/dimension.rb', line 19

def new *args
  instances.find { |

Instance Method Details

#to_sObject

Short instance description string.



35
36
37
# File 'lib/y_nelson/dimension.rb', line 35

def to_s
  "#<YNelson::Dimension [#{object.join ', '}]>"
end