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.
9
10
11
12
|
# File 'lib/typical/type/list.rb', line 9
def initialize(*objects)
@storage = new_storage
load_from_objects(objects)
end
|
Instance Attribute Details
#storage ⇒ Object
Returns the value of attribute storage.
7
8
9
|
# File 'lib/typical/type/list.rb', line 7
def storage
@storage
end
|
Instance Method Details
#==(other) ⇒ Object
30
31
32
|
# File 'lib/typical/type/list.rb', line 30
def ==(other)
other.is_a?(self.class) && values == other.values
end
|
#empty? ⇒ Boolean
26
27
28
|
# File 'lib/typical/type/list.rb', line 26
def empty?
values.empty?
end
|
#eql?(other) ⇒ Boolean
34
35
36
|
# File 'lib/typical/type/list.rb', line 34
def eql?(other)
super && @storage == other.storage
end
|
#hash ⇒ Object
38
39
40
|
# File 'lib/typical/type/list.rb', line 38
def hash
[super, @storage].hash
end
|
#inspect ⇒ Object
42
43
44
|
# File 'lib/typical/type/list.rb', line 42
def inspect
"#<Type:#{type} [#{values.inspect}]>"
end
|
#normalize ⇒ Object
14
15
16
|
# File 'lib/typical/type/list.rb', line 14
def normalize
self.class.new.tap { |copy| copy.values = values.normalize(false) }
end
|
#values ⇒ Object
18
19
20
|
# File 'lib/typical/type/list.rb', line 18
def values
@storage[:values]
end
|
#values=(values) ⇒ Object
22
23
24
|
# File 'lib/typical/type/list.rb', line 22
def values=(values)
@storage[:values] = values
end
|