Class | Kwalify::Rule
In: | kwalify/rule.rb
Parent: | Object

### Methods

_init _inspect get_init_method new

### Included Modules

Kwalify::ErrorHelper

### Attributes

assert | [R] |
assert_proc | [R] |
classname | [R] |
classobj | [R] |
default | [R] |
desc | [R] |
enum | [R] |
ident | [R] |
length | [R] |
mapping | [R] |
name | [R] |
parent | [RW] |
pattern | [R] |
range | [R] |
regexp | [R] |
required | [R] |
sequence | [R] |
type | [R] |
type_class | [R] |
unique | [R] |

### Public Class methods

new(hash=nil, parent=nil)

[Source]

    # File kwalify/rule.rb, line 40
        def initialize(hash=nil, parent=nil)
          _init(hash, "", {}) if hash
          @parent = parent
        end

### Public Instance methods

_init(hash, path="", rule_table={})

[Source]

    # File kwalify/rule.rb, line 46
        def _init(hash, path="", rule_table={})
          unless hash.is_a?(Hash)
            #* key=:schema_notmap  msg="schema definition is not a mapping."
            raise Kwalify.schema_error(:schema_notmap, nil, (!path || path.empty? ? "/" : path), nil)
          end
          rule = self
          rule_table[hash.__id__] = rule
          ## 'type:' entry
          curr_path = "#{path}/type"
          _init_type_value(hash['type'], rule, curr_path)
          ## other entries
          hash.each do |key, val|
            curr_path = "#{path}/#{key}"
            sym = key.intern
            method = get_init_method(sym)
            unless method
              #* key=:key_unknown  msg="unknown key."
              raise schema_error(:key_unknown, rule, curr_path, "#{key}:")
            end
            if sym == :sequence || sym == :mapping
              __send__(method, val, rule, curr_path, rule_table)
            else
              __send__(method, val, rule, curr_path)
            end
          end
          _check_confliction(hash, rule, path)
          return self
        end

### Protected Instance methods

_inspect(str="", level=0, done={})

def inspect()

      str = "";  level = 0;  done = {}
      _inspect(str, level, done)
      return str

end

[Source]

    # File kwalify/rule.rb, line 473
        def _inspect(str="", level=0, done={})
          done[self.__id__] = true
          str << "  " * level << "name:    #{@name}\n"         unless @name.nil?
          str << "  " * level << "desc:    #{@desc}\n"         unless @desc.nil?
          str << "  " * level << "type:    #{@type}\n"         unless @type.nil?
          str << "  " * level << "klass:    #{@type_class.name}\n"  unless @type_class.nil?
          str << "  " * level << "required:  #{@required}\n"      unless @required.nil?
          str << "  " * level << "pattern:  #{@regexp.inspect}\n"  unless @pattern.nil?
          str << "  " * level << "assert:   #{@assert}\n"        unless @assert.nil?
          str << "  " * level << "ident:    #{@ident}\n"        unless @ident.nil?
          str << "  " * level << "unique:   #{@unique}\n"        unless @unique.nil?
          if !@enum.nil?
            str << "  " * level << "enum:\n"
            @enum.each do |item|
              str << "  " * (level+1) << "- #{item}\n"
            end
          end
          if !@range.nil?
            str << "  " * level
            str << "range:    { "
            colon = ""
            %w[max max-ex min min-ex].each do |key|
              val = @range[key]
              unless val.nil?
                str << colon << "#{key}: #{val.inspect}"
                colon = ", "
              end
            end
            str << " }\n"
          end
          if !@length.nil?
            str << "  " * level
            str << "length:    { "
            colon = ""
            %w[max max-ex min min-ex].each do |key|
              val = @length[key]
              if !val.nil?
                str << colon << "#{key}: #{val.inspect}"
                colon = ", "
              end
            end
            str << " }\n"
          end
          @sequence.each do |rule|
            if done[rule.__id__]
              str << "  " * (level+1) << "- ...\n"
            else
              str << "  " * (level+1) << "- \n"
              rule._inspect(str, level+2, done)
            end
          end if @sequence
          @mapping.each do |key, rule|
            if done[rule.__id__]
              str << '  ' * (level+1) << '"' << key << "\": ...\n"
            else
              str << '  ' * (level+1) << '"' << key << "\":\n"
              rule._inspect(str, level+2, done)
            end
          end if @mapping
          return str
        end

get_init_method(sym)

[Source]

    # File kwalify/rule.rb, line 86
        def get_init_method(sym)
          @_dispatch_table ||= @@dispatch_table
          return @_dispatch_table[sym]
        end

[Validate]