Module: Finitio::HeadingBasedType
- Included in:
- MultiRelationType, MultiTupleType, RelationType, TupleType
- Defined in:
- lib/finitio/type/heading_based_type.rb
Instance Attribute Summary collapse
-
#heading ⇒ Object
readonly
Returns the value of attribute heading.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](attrname) ⇒ Object
- #hash ⇒ Object
- #initialize(heading, name = nil, metadata = nil) ⇒ Object
- #resolve_proxies(system) ⇒ Object
- #suppremum(other, simple_class, multi_class) ⇒ Object
- #unconstrained ⇒ Object
Instance Attribute Details
#heading ⇒ Object (readonly)
Returns the value of attribute heading.
12 13 14 |
# File 'lib/finitio/type/heading_based_type.rb', line 12 def heading @heading end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
27 28 29 |
# File 'lib/finitio/type/heading_based_type.rb', line 27 def ==(other) super || (other.is_a?(self.class) && heading == other.heading) end |
#[](attrname) ⇒ Object
14 15 16 |
# File 'lib/finitio/type/heading_based_type.rb', line 14 def [](attrname) heading.fetch(attrname) end |
#hash ⇒ Object
32 33 34 |
# File 'lib/finitio/type/heading_based_type.rb', line 32 def hash self.class.hash ^ heading.hash end |
#initialize(heading, name = nil, metadata = nil) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/finitio/type/heading_based_type.rb', line 4 def initialize(heading, name = nil, = nil) unless heading.is_a?(Heading) raise ArgumentError, "Heading expected, got `#{heading}`" end super(name, ) @heading = heading end |
#resolve_proxies(system) ⇒ Object
36 37 38 |
# File 'lib/finitio/type/heading_based_type.rb', line 36 def resolve_proxies(system) self.class.new(heading.resolve_proxies(system), name, ) end |
#suppremum(other, simple_class, multi_class) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/finitio/type/heading_based_type.rb', line 18 def suppremum(other, simple_class, multi_class) return self if self == other return super(other) unless other.is_a?(simple_class) or other.is_a?(multi_class) return super(other) unless heading.looks_similar?(other.heading) result_heading = heading.suppremum(other.heading) builder = result_heading.multi? ? multi_class : simple_class builder.new(result_heading) end |
#unconstrained ⇒ Object
40 41 42 |
# File 'lib/finitio/type/heading_based_type.rb', line 40 def unconstrained self.class.new(heading.unconstrained, name, ) end |