Sha256: a8e1fd4bb681ee86bdd5532d553d4d0e8f6b7c31d405818f5f5641d4353b60d8
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
module Finitio # # Helper class for tuple and relation types. # # A heading is a set of attributes, with the constraint that no two # attributes have the same name. # class Heading include Enumerable def initialize(attributes) unless attributes.is_a?(Enumerable) and \ attributes.all?{|a| a.is_a?(Attribute) } raise ArgumentError, "Enumerable[Attribute] expected" end @attributes = {} attributes.each do |attr| if @attributes[attr.name] raise ArgumentError, "Attribute names must be unique" end @attributes[attr.name] = attr end @attributes.freeze end def size @attributes.size end def empty? size == 0 end def each(&bl) return to_enum unless bl @attributes.values.each(&bl) end def to_name map(&:to_name).join(', ') end def ==(other) return nil unless other.is_a?(Heading) attributes == other.attributes end def hash self.class.hash ^ attributes.hash end attr_reader :attributes protected :attributes end # class Heading end # class Finitio
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finitio-0.4.1 | lib/finitio/support/heading.rb |
finitio-0.4.0 | lib/finitio/support/heading.rb |