striuct 0.4.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE.txt +21 -0
- data/README.md +20 -41
- data/lib/striuct.rb +3 -3
- data/lib/striuct/classmethods/README.md +2 -2
- data/lib/striuct/classmethods/adjustment.rb +15 -13
- data/lib/striuct/classmethods/attributes.rb +93 -91
- data/lib/striuct/classmethods/conflict_management.rb +109 -106
- data/lib/striuct/classmethods/constructor.rb +47 -54
- data/lib/striuct/classmethods/copy.rb +45 -43
- data/lib/striuct/classmethods/default.rb +23 -21
- data/lib/striuct/classmethods/enum.rb +46 -44
- data/lib/striuct/classmethods/fix.rb +23 -21
- data/lib/striuct/classmethods/hashdeepdupulicatable.rb +14 -16
- data/lib/striuct/classmethods/inner.rb +57 -64
- data/lib/striuct/classmethods/length.rb +12 -10
- data/lib/striuct/classmethods/macro.rb +109 -111
- data/lib/striuct/classmethods/names.rb +69 -65
- data/lib/striuct/classmethods/predicate.rb +131 -138
- data/lib/striuct/classmethods/requirements.rb +3 -1
- data/lib/striuct/classmethods/to_struct.rb +21 -18
- data/lib/striuct/classmethods/validation.rb +15 -13
- data/lib/striuct/instancemethods/README.md +2 -2
- data/lib/striuct/instancemethods/assign.rb +29 -27
- data/lib/striuct/instancemethods/cast.rb +28 -26
- data/lib/striuct/instancemethods/compare.rb +26 -24
- data/lib/striuct/instancemethods/default.rb +31 -29
- data/lib/striuct/instancemethods/delegate_class_methods.rb +36 -32
- data/lib/striuct/instancemethods/enum.rb +86 -84
- data/lib/striuct/instancemethods/getter.rb +39 -37
- data/lib/striuct/instancemethods/hashy.rb +99 -97
- data/lib/striuct/instancemethods/keyvalidatable.rb +8 -6
- data/lib/striuct/instancemethods/lock.rb +46 -44
- data/lib/striuct/instancemethods/object.rb +50 -48
- data/lib/striuct/instancemethods/requirements.rb +11 -9
- data/lib/striuct/instancemethods/safety.rb +11 -9
- data/lib/striuct/instancemethods/setter.rb +46 -49
- data/lib/striuct/instancemethods/to_s.rb +39 -37
- data/lib/striuct/instancemethods/validation.rb +31 -29
- data/lib/striuct/instancemethods/values.rb +52 -33
- data/lib/striuct/requirements.rb +3 -1
- data/lib/striuct/singleton_class.rb +12 -17
- data/lib/striuct/structs.rb +3 -3
- metadata +48 -186
- data/.gitignore +0 -35
- data/.travis.yml +0 -20
- data/.yardopts +0 -1
- data/Gemfile +0 -11
- data/History.old(~0.3.n).rdoc +0 -289
- data/MIT-LICENSE +0 -22
- data/Rakefile +0 -10
- data/benchmark/basics.rb +0 -56
- data/example/README.rb +0 -53
- data/example/example1.rb +0 -235
- data/example/example2.rb +0 -22
- data/example/see_trace.rb +0 -32
- data/striuct.gemspec +0 -36
- data/test/helper.rb +0 -5
- data/test/test_sglc-constructor.rb +0 -36
- data/test/test_subc-c-add_members.rb +0 -13
- data/test/test_subc-c-close_member.rb +0 -36
- data/test/test_subc-c-constructor.rb +0 -92
- data/test/test_subc-c-copy.rb +0 -71
- data/test/test_subc-c-freeze.rb +0 -36
- data/test/test_subc-c-inheritable.rb +0 -58
- data/test/test_subc-c-safety_naming.rb +0 -73
- data/test/test_subc-f-alias_member.rb +0 -54
- data/test/test_subc-f-enum.rb +0 -139
- data/test/test_subc-f-predicate.rb +0 -711
- data/test/test_subc-f-to_struct.rb +0 -61
- data/test/test_subc-f-validation_util.rb +0 -59
- data/test/test_subc-f_debug.rb +0 -39
- data/test/test_subc-f_name.rb +0 -525
- data/test/test_subc-i-accessor.rb +0 -138
- data/test/test_subc-i-adjuster.rb +0 -95
- data/test/test_subc-i-assign.rb +0 -53
- data/test/test_subc-i-basic.rb +0 -32
- data/test/test_subc-i-cast.rb +0 -27
- data/test/test_subc-i-compare.rb +0 -52
- data/test/test_subc-i-copy.rb +0 -23
- data/test/test_subc-i-default_value.rb +0 -129
- data/test/test_subc-i-freeze.rb +0 -19
- data/test/test_subc-i-hashlike.rb +0 -144
- data/test/test_subc-i-keyvalidatable.rb +0 -25
- data/test/test_subc-i-lock.rb +0 -40
- data/test/test_subc-i-must.rb +0 -30
- data/test/test_subc-i-to_s_family.rb +0 -26
- data/test/test_subc-i-validation_inference.rb +0 -51
- data/test/test_subc-i-validation_specific_conditions.rb +0 -297
- data/test/test_subc-i-validation_with_getter.rb +0 -33
- data/test/test_version.rb +0 -13
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'optionalargument'
         | 
| 2 4 |  | 
| 3 5 | 
             
            require_relative 'hashdeepdupulicatable'
         | 
| @@ -15,4 +17,4 @@ require_relative 'default' | |
| 15 17 | 
             
            require_relative 'adjustment'
         | 
| 16 18 | 
             
            require_relative 'macro'
         | 
| 17 19 | 
             
            require_relative 'conflict_management'
         | 
| 18 | 
            -
            require_relative 'validation'
         | 
| 20 | 
            +
            require_relative 'validation'
         | 
| @@ -1,24 +1,27 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module ClassMethods
         | 
| 5 | 
            +
                # @group To Ruby's Struct Class
         | 
| 4 6 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 7 | 
            +
                # @return [Class]
         | 
| 8 | 
            +
                def to_struct_class
         | 
| 9 | 
            +
                  raise 'No defined members' if autonyms.empty?
         | 
| 8 10 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            +
                  struct_cls = ::Struct.new(*autonyms)
         | 
| 12 | 
            +
                  return struct_cls unless name
         | 
| 11 13 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                   already_cls
         | 
| 17 | 
            -
                else
         | 
| 18 | 
            -
                  ::Striuct::Structs.const_set const_suffix, struct_cls
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
              end
         | 
| 14 | 
            +
                  const_suffix = name.slice(/[^:]+\z/).to_sym
         | 
| 15 | 
            +
                  if ::Striuct::Structs.const_defined?(const_suffix, false) &&
         | 
| 16 | 
            +
                     (already_cls = ::Striuct::Structs.const_get(const_suffix, false)).members == autonyms
         | 
| 17 | 
            +
                    raise unless already_cls.superclass.equal?(Struct)
         | 
| 21 18 |  | 
| 22 | 
            -
             | 
| 19 | 
            +
                    already_cls
         | 
| 20 | 
            +
                  else
         | 
| 21 | 
            +
                    ::Striuct::Structs.const_set(const_suffix, struct_cls)
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 23 24 |  | 
| 24 | 
            -
             | 
| 25 | 
            +
                # @endgroup
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -1,15 +1,17 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
              
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              def condition_for(key)
         | 
| 7 | 
            -
                autonym = autonym_for_key key
         | 
| 8 | 
            -
                raise KeyError unless with_condition? autonym
         | 
| 9 | 
            -
                
         | 
| 10 | 
            -
                _attributes_for(autonym).condition
         | 
| 11 | 
            -
              end
         | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module ClassMethods
         | 
| 5 | 
            +
                # @group Validation
         | 
| 12 6 |  | 
| 13 | 
            -
             | 
| 7 | 
            +
                # @param [Symbol, String, #to_sym, Integer, #to_int] key - name / index
         | 
| 8 | 
            +
                def condition_for(key)
         | 
| 9 | 
            +
                  autonym = autonym_for_key(key)
         | 
| 10 | 
            +
                  raise KeyError unless with_condition?(autonym)
         | 
| 14 11 |  | 
| 15 | 
            -
             | 
| 12 | 
            +
                  _attributes_for(autonym).condition
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                # @endgroup
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| @@ -1,33 +1,35 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
              
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              def assigned?(key)
         | 
| 7 | 
            -
                @db.has_key? autonym_for_key(key)
         | 
| 8 | 
            -
              end
         | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module InstanceMethods
         | 
| 5 | 
            +
                # @group Assign / Unassign
         | 
| 9 6 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
              # @return value / nil - value assigned under the key
         | 
| 14 | 
            -
              def unassign(key)
         | 
| 15 | 
            -
                _check_frozen
         | 
| 16 | 
            -
                _check_locked key
         | 
| 17 | 
            -
                if must? key
         | 
| 18 | 
            -
                  raise InvalidOperationError, "`#{key}` require a value under `must` option"
         | 
| 7 | 
            +
                # @param [Symbol, String, #to_sym, Integer, #to_int] key - name / index
         | 
| 8 | 
            +
                def assigned?(key)
         | 
| 9 | 
            +
                  @db.key?(autonym_for_key(key))
         | 
| 19 10 | 
             
                end
         | 
| 20 | 
            -
                
         | 
| 21 | 
            -
                @db.delete autonym_for_key(key)
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
              
         | 
| 24 | 
            -
              alias_method :delete_at, :unassign
         | 
| 25 11 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
              def empty?
         | 
| 28 | 
            -
                _autonyms.none?{|autonym|@db.has_key? autonym}
         | 
| 29 | 
            -
              end
         | 
| 12 | 
            +
                alias_method :assign?, :assigned?
         | 
| 30 13 |  | 
| 31 | 
            -
             | 
| 14 | 
            +
                # @param [Symbol, String, #to_sym, Integer, #to_int] key - name / index
         | 
| 15 | 
            +
                # @return value / nil - value assigned under the key
         | 
| 16 | 
            +
                def unassign(key)
         | 
| 17 | 
            +
                  _check_frozen
         | 
| 18 | 
            +
                  _check_locked(key)
         | 
| 19 | 
            +
                  if must?(key)
         | 
| 20 | 
            +
                    raise InvalidOperationError, "`#{key}` require a value under `must` option"
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  @db.delete(autonym_for_key(key))
         | 
| 24 | 
            +
                end
         | 
| 32 25 |  | 
| 33 | 
            -
             | 
| 26 | 
            +
                alias_method :delete_at, :unassign
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                # true if all members are not yet assigned
         | 
| 29 | 
            +
                def empty?
         | 
| 30 | 
            +
                  _autonyms.none? { |autonym| @db.key?(autonym) }
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                # @endgroup
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
| @@ -1,32 +1,34 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module InstanceMethods
         | 
| 5 | 
            +
                # @group Cast
         | 
| 4 6 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 7 | 
            +
                # @return [self]
         | 
| 8 | 
            +
                def to_striuct
         | 
| 9 | 
            +
                  self
         | 
| 10 | 
            +
                end
         | 
| 9 11 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
              
         | 
| 15 | 
            -
              # @param [Boolean] include_no_assign
         | 
| 16 | 
            -
              # @return [Hash]
         | 
| 17 | 
            -
              def to_h(include_no_assign=true)
         | 
| 18 | 
            -
                return @db.dup unless include_no_assign
         | 
| 12 | 
            +
                # @return [Struct]
         | 
| 13 | 
            +
                def to_struct
         | 
| 14 | 
            +
                  self.class.to_struct_class.new(*values)
         | 
| 15 | 
            +
                end
         | 
| 19 16 |  | 
| 20 | 
            -
                 | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
              def values
         | 
| 25 | 
            -
                each_value.to_a
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
              
         | 
| 28 | 
            -
              alias_method :to_a, :values
         | 
| 17 | 
            +
                # @param [Boolean] include_no_assign
         | 
| 18 | 
            +
                # @return [Hash]
         | 
| 19 | 
            +
                def to_h(include_no_assign: true)
         | 
| 20 | 
            +
                  return @db.dup unless include_no_assign
         | 
| 29 21 |  | 
| 30 | 
            -
             | 
| 22 | 
            +
                  each_pair.to_a.to_h
         | 
| 23 | 
            +
                end
         | 
| 31 24 |  | 
| 32 | 
            -
             | 
| 25 | 
            +
                # @return [Array]
         | 
| 26 | 
            +
                def values
         | 
| 27 | 
            +
                  each_value.to_a
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                alias_method :to_a, :values
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                # @endgroup
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| @@ -1,30 +1,32 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
              # @group Compare with other
         | 
| 4 | 
            -
              
         | 
| 5 | 
            -
              # @return [Boolean]
         | 
| 6 | 
            -
              def ==(other)
         | 
| 7 | 
            -
                other.instance_of?(self.class) && 
         | 
| 8 | 
            -
                  each_pair.all?{|autonym, val|other._get(autonym) == val}
         | 
| 9 | 
            -
              end
         | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 10 2 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
              
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                other.instance_of?(self.class) && other._db.eql?(@db)
         | 
| 15 | 
            -
              end
         | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module InstanceMethods
         | 
| 5 | 
            +
                # @group Compare with other
         | 
| 16 6 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 7 | 
            +
                # @return [Boolean]
         | 
| 8 | 
            +
                def ==(other)
         | 
| 9 | 
            +
                  other.instance_of?(self.class) &&
         | 
| 10 | 
            +
                    each_pair.all? { |autonym, val| other._get(autonym) == val }
         | 
| 11 | 
            +
                end
         | 
| 21 12 |  | 
| 22 | 
            -
             | 
| 13 | 
            +
                alias_method :===, :==
         | 
| 23 14 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 15 | 
            +
                def eql?(other)
         | 
| 16 | 
            +
                  other.instance_of?(self.class) && other._db.eql?(@db)
         | 
| 17 | 
            +
                end
         | 
| 27 18 |  | 
| 28 | 
            -
             | 
| 19 | 
            +
                # @return [Integer]
         | 
| 20 | 
            +
                def hash
         | 
| 21 | 
            +
                  @db.hash
         | 
| 22 | 
            +
                end
         | 
| 29 23 |  | 
| 30 | 
            -
             | 
| 24 | 
            +
                protected
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def _db
         | 
| 27 | 
            +
                  @db
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                # @endgroup
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -1,36 +1,38 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              def default?(key)
         | 
| 7 | 
            -
                autonym = autonym_for_key key
         | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module InstanceMethods
         | 
| 5 | 
            +
                # @group Default Value
         | 
| 8 6 |  | 
| 9 | 
            -
                 | 
| 10 | 
            -
             | 
| 7 | 
            +
                # @param [Symbol, String, #to_sym, Integer, #to_int] key - name / index
         | 
| 8 | 
            +
                def default?(key)
         | 
| 9 | 
            +
                  autonym = autonym_for_key(key)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  default_value_for(autonym) == fetch_by_autonym(autonym)
         | 
| 12 | 
            +
                end
         | 
| 11 13 |  | 
| 12 | 
            -
             | 
| 14 | 
            +
                private
         | 
| 13 15 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 16 | 
            +
                # @param [Symbol] target_autonyms - MUST already converted to native autonym
         | 
| 17 | 
            +
                # @return [self]
         | 
| 18 | 
            +
                def _set_defaults(*target_autonyms)
         | 
| 19 | 
            +
                  target_autonyms.each do |autonym|
         | 
| 20 | 
            +
                    if with_default?(autonym)
         | 
| 21 | 
            +
                      default = default_value_for(autonym)
         | 
| 22 | 
            +
                      _set(autonym, (
         | 
| 23 | 
            +
                        if default_type_for(autonym) == :lazy
         | 
| 24 | 
            +
                          args = [self, autonym][0, default.arity]
         | 
| 25 | 
            +
                          default.call(*args)
         | 
| 26 | 
            +
                        else
         | 
| 27 | 
            +
                          default
         | 
| 28 | 
            +
                        end
         | 
| 29 | 
            +
                      ))
         | 
| 30 | 
            +
                    end
         | 
| 28 31 | 
             
                  end
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
                
         | 
| 31 | 
            -
                self
         | 
| 32 | 
            -
              end
         | 
| 33 32 |  | 
| 34 | 
            -
             | 
| 33 | 
            +
                  self
         | 
| 34 | 
            +
                end
         | 
| 35 35 |  | 
| 36 | 
            -
             | 
| 36 | 
            +
                # @endgroup
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -1,35 +1,39 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
              
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                :_autonyms,
         | 
| 7 | 
            -
                :autonym_for_alias,
         | 
| 8 | 
            -
                :autonym_for_member,
         | 
| 9 | 
            -
                :autonym_for_index,
         | 
| 10 | 
            -
                :autonym_for_key,
         | 
| 11 | 
            -
                :autonyms, :members, :all_members, :aliases, :attributes,
         | 
| 12 | 
            -
                :has_autonym?, :autonym?,
         | 
| 13 | 
            -
                :has_alias?, :alias?, :aliased?,
         | 
| 14 | 
            -
                :has_member?, :member?,
         | 
| 15 | 
            -
                :has_index?, :index?,
         | 
| 16 | 
            -
                :has_key?, :key?,
         | 
| 17 | 
            -
                :with_aliases?,
         | 
| 18 | 
            -
                :aliases_for_autonym,
         | 
| 19 | 
            -
                :length, :size,
         | 
| 20 | 
            -
                :with_condition?, :restrict?,
         | 
| 21 | 
            -
                :condition_for,
         | 
| 22 | 
            -
                :with_safety_getter?, :with_safety_reader?,
         | 
| 23 | 
            -
                :with_safety_setter?, :with_safety_writer?,
         | 
| 24 | 
            -
                :with_inference?,
         | 
| 25 | 
            -
                :with_must?, :must?,
         | 
| 26 | 
            -
                :with_default?,
         | 
| 27 | 
            -
                :default_value_for, :default_type_for,
         | 
| 28 | 
            -
                :with_adjuster?,
         | 
| 29 | 
            -
                :adjuster_for
         | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module InstanceMethods
         | 
| 5 | 
            +
                # @group Delegate Class Methods
         | 
| 30 6 |  | 
| 31 | 
            -
             | 
| 7 | 
            +
                def_delegators :'self.class',
         | 
| 8 | 
            +
                               :autonym_for_alias,
         | 
| 9 | 
            +
                               :autonym_for_member,
         | 
| 10 | 
            +
                               :autonym_for_index,
         | 
| 11 | 
            +
                               :autonym_for_key,
         | 
| 12 | 
            +
                               :autonyms, :members, :all_members, :aliases, :attributes,
         | 
| 13 | 
            +
                               :has_autonym?, :autonym?,
         | 
| 14 | 
            +
                               :has_alias?, :alias?, :aliased?,
         | 
| 15 | 
            +
                               :has_member?, :member?,
         | 
| 16 | 
            +
                               :has_index?, :index?,
         | 
| 17 | 
            +
                               :has_key?, :key?,
         | 
| 18 | 
            +
                               :with_aliases?,
         | 
| 19 | 
            +
                               :aliases_for_autonym,
         | 
| 20 | 
            +
                               :length, :size,
         | 
| 21 | 
            +
                               :with_condition?, :restrict?,
         | 
| 22 | 
            +
                               :condition_for,
         | 
| 23 | 
            +
                               :with_safety_getter?, :with_safety_reader?,
         | 
| 24 | 
            +
                               :with_safety_setter?, :with_safety_writer?,
         | 
| 25 | 
            +
                               :with_must?, :must?,
         | 
| 26 | 
            +
                               :with_default?,
         | 
| 27 | 
            +
                               :default_value_for, :default_type_for,
         | 
| 28 | 
            +
                               :with_adjuster?,
         | 
| 29 | 
            +
                               :adjuster_for
         | 
| 32 30 |  | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 31 | 
            +
                private
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def _autonyms
         | 
| 34 | 
            +
                  self.class.__send__(:_autonyms)
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                # @endgroup
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| @@ -1,98 +1,100 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            class Striuct
         | 
| 4 | 
            +
              module InstanceMethods
         | 
| 5 | 
            +
                # @group Enumerative
         | 
| 4 6 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 7 | 
            +
                # @yield [autonym]
         | 
| 8 | 
            +
                # @yieldparam [Symbol] autonym - sequential under defined
         | 
| 9 | 
            +
                # @yieldreturn [self]
         | 
| 10 | 
            +
                # @return [Enumerator]
         | 
| 11 | 
            +
                def each_autonym(&block)
         | 
| 12 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block
         | 
| 11 13 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 14 | 
            +
                  self.class.each_autonym(&block)
         | 
| 15 | 
            +
                  self
         | 
| 16 | 
            +
                end
         | 
| 15 17 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
              # @yield [value]
         | 
| 19 | 
            -
              # @yieldparam [Object] value - sequential under defined
         | 
| 20 | 
            -
              # @see #each_autonym
         | 
| 21 | 
            -
              # @yieldreturn [self]
         | 
| 22 | 
            -
              # @return [Enumerator]
         | 
| 23 | 
            -
              def each_value
         | 
| 24 | 
            -
                return to_enum(__callee__) unless block_given?
         | 
| 25 | 
            -
              
         | 
| 26 | 
            -
                each_autonym{|autonym|yield _get(autonym)}
         | 
| 27 | 
            -
              end
         | 
| 28 | 
            -
              
         | 
| 29 | 
            -
              alias_method :each, :each_value
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              # @yield [autonym, value]
         | 
| 32 | 
            -
              # @yieldparam [Symbol] autonym
         | 
| 33 | 
            -
              # @yieldparam [Object] value
         | 
| 34 | 
            -
              # @yieldreturn [self]
         | 
| 35 | 
            -
              # @return [Enumerator]
         | 
| 36 | 
            -
              # @see #each_autonym
         | 
| 37 | 
            -
              # @see #each_value 
         | 
| 38 | 
            -
              def each_pair
         | 
| 39 | 
            -
                return to_enum(__callee__) unless block_given?
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                each_autonym{|autonym|yield autonym, _get(autonym)}
         | 
| 42 | 
            -
              end
         | 
| 18 | 
            +
                alias_method :each_member, :each_autonym
         | 
| 43 19 |  | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
                 | 
| 20 | 
            +
                # @yield [value]
         | 
| 21 | 
            +
                # @yieldparam [Object] value - sequential under defined
         | 
| 22 | 
            +
                # @see #each_autonym
         | 
| 23 | 
            +
                # @yieldreturn [self]
         | 
| 24 | 
            +
                # @return [Enumerator]
         | 
| 25 | 
            +
                def each_value
         | 
| 26 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block_given?
         | 
| 50 27 |  | 
| 51 | 
            -
             | 
| 52 | 
            -
                 | 
| 53 | 
            -
              end
         | 
| 28 | 
            +
                  each_autonym { |autonym| yield _get(autonym) }
         | 
| 29 | 
            +
                end
         | 
| 54 30 |  | 
| 55 | 
            -
             | 
| 56 | 
            -
              # @yieldparam [Symbol] autonym
         | 
| 57 | 
            -
              # @yieldparam [Integer] index
         | 
| 58 | 
            -
              # @yieldreturn [self]
         | 
| 59 | 
            -
              # @return [Enumerator]
         | 
| 60 | 
            -
              def each_autonym_with_index
         | 
| 61 | 
            -
                return to_enum(__callee__) unless block_given?
         | 
| 31 | 
            +
                alias_method :each, :each_value
         | 
| 62 32 |  | 
| 63 | 
            -
                 | 
| 64 | 
            -
                 | 
| 65 | 
            -
             | 
| 33 | 
            +
                # @yield [autonym, value]
         | 
| 34 | 
            +
                # @yieldparam [Symbol] autonym
         | 
| 35 | 
            +
                # @yieldparam [Object] value
         | 
| 36 | 
            +
                # @yieldreturn [self]
         | 
| 37 | 
            +
                # @return [Enumerator]
         | 
| 38 | 
            +
                # @see #each_autonym
         | 
| 39 | 
            +
                # @see #each_value
         | 
| 40 | 
            +
                def each_pair
         | 
| 41 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block_given?
         | 
| 66 42 |  | 
| 67 | 
            -
             | 
| 43 | 
            +
                  each_autonym { |autonym| yield autonym, _get(autonym) }
         | 
| 44 | 
            +
                end
         | 
| 68 45 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 46 | 
            +
                # @yield [index]
         | 
| 47 | 
            +
                # @yieldparam [Integer] index
         | 
| 48 | 
            +
                # @yieldreturn [self]
         | 
| 49 | 
            +
                # @return [Enumerator]
         | 
| 50 | 
            +
                def each_index
         | 
| 51 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block_given?
         | 
| 75 52 |  | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
              
         | 
| 79 | 
            -
              alias_method :each_with_index, :each_value_with_index
         | 
| 80 | 
            -
              
         | 
| 81 | 
            -
              # @yield [autonym, value, index]
         | 
| 82 | 
            -
              # @yieldparam [Symbol] autonym
         | 
| 83 | 
            -
              # @yieldparam [Integer] index
         | 
| 84 | 
            -
              # @yieldreturn [self]
         | 
| 85 | 
            -
              # @return [Enumerator]
         | 
| 86 | 
            -
              def each_pair_with_index
         | 
| 87 | 
            -
                return to_enum(__callee__) unless block_given?
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                index = 0
         | 
| 90 | 
            -
                each_pair do |autonym, value|
         | 
| 91 | 
            -
                  yield autonym, value, index
         | 
| 92 | 
            -
                  index += 1
         | 
| 53 | 
            +
                  self.class.each_index { |index| yield index }
         | 
| 54 | 
            +
                  self
         | 
| 93 55 | 
             
                end
         | 
| 94 | 
            -
              end
         | 
| 95 56 |  | 
| 96 | 
            -
             | 
| 57 | 
            +
                # @yield [autonym, index]
         | 
| 58 | 
            +
                # @yieldparam [Symbol] autonym
         | 
| 59 | 
            +
                # @yieldparam [Integer] index
         | 
| 60 | 
            +
                # @yieldreturn [self]
         | 
| 61 | 
            +
                # @return [Enumerator]
         | 
| 62 | 
            +
                def each_autonym_with_index
         | 
| 63 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block_given?
         | 
| 97 64 |  | 
| 98 | 
            -
             | 
| 65 | 
            +
                  self.class.each_autonym_with_index { |autonym, index| yield autonym, index }
         | 
| 66 | 
            +
                  self
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                alias_method :each_member_with_index, :each_autonym_with_index
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                # @yield [value, index]
         | 
| 72 | 
            +
                # @yieldparam [Integer] index
         | 
| 73 | 
            +
                # @yieldreturn [self]
         | 
| 74 | 
            +
                # @return [Enumerator]
         | 
| 75 | 
            +
                def each_value_with_index
         | 
| 76 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block_given?
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  each_value.with_index { |value, index| yield value, index }
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                alias_method :each_with_index, :each_value_with_index
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                # @yield [autonym, value, index]
         | 
| 84 | 
            +
                # @yieldparam [Symbol] autonym
         | 
| 85 | 
            +
                # @yieldparam [Integer] index
         | 
| 86 | 
            +
                # @yieldreturn [self]
         | 
| 87 | 
            +
                # @return [Enumerator]
         | 
| 88 | 
            +
                def each_pair_with_index
         | 
| 89 | 
            +
                  return to_enum(__callee__) { self.class.size } unless block_given?
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                  index = 0
         | 
| 92 | 
            +
                  each_pair do |autonym, value|
         | 
| 93 | 
            +
                    yield autonym, value, index
         | 
| 94 | 
            +
                    index += 1
         | 
| 95 | 
            +
                  end
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                # @endgroup
         | 
| 99 | 
            +
              end
         | 
| 100 | 
            +
            end
         |