Class: Typical::Type::List
Instance Attribute Summary collapse
#type
Instance Method Summary
collapse
#nullable?, of, #prominent_type, #types, #|
Constructor Details
#initialize(*objects) ⇒ List
Returns a new instance of List.
8
9
10
11
|
# File 'lib/typical/type/list.rb', line 8
def initialize(*objects)
@storage = new_storage
load_from_objects(objects)
end
|
Instance Attribute Details
#storage ⇒ Object
Returns the value of attribute storage.
6
7
8
|
# File 'lib/typical/type/list.rb', line 6
def storage
@storage
end
|
Instance Method Details
#==(other) ⇒ Object
29
30
31
|
# File 'lib/typical/type/list.rb', line 29
def ==(other)
other.is_a?(self.class) && values == other.values
end
|
#empty? ⇒ Boolean
25
26
27
|
# File 'lib/typical/type/list.rb', line 25
def empty?
values.empty?
end
|
#eql?(other) ⇒ Boolean
33
34
35
|
# File 'lib/typical/type/list.rb', line 33
def eql?(other)
super && @storage == other.storage
end
|
#hash ⇒ Object
37
38
39
|
# File 'lib/typical/type/list.rb', line 37
def hash
[super, @storage].hash
end
|
#inspect ⇒ Object
41
42
43
|
# File 'lib/typical/type/list.rb', line 41
def inspect
"#<Type:#{type} [#{values.inspect}]>"
end
|
#normalize ⇒ Object
13
14
15
|
# File 'lib/typical/type/list.rb', line 13
def normalize
self.class.new.tap { |copy| copy.values = values.normalize(false) }
end
|
#values ⇒ Object
17
18
19
|
# File 'lib/typical/type/list.rb', line 17
def values
@storage[:values]
end
|
#values=(values) ⇒ Object
21
22
23
|
# File 'lib/typical/type/list.rb', line 21
def values=(values)
@storage[:values] = values
end
|