class MightyJSON::Type::Array
Public Class Methods
new(type)
click to toggle source
# File lib/mighty_json/type.rb, line 116 def initialize(type) @type = type end
Public Instance Methods
compile(var:, path:)
click to toggle source
# File lib/mighty_json/type.rb, line 120 def compile(var:, path:) v = var.cur idx = var.next child = var.next <<~END begin raise Error.new(path: #{path.inspect}, type: #{self.to_s.inspect}, value: #{v}) unless #{v}.is_a?(::Array) #{v}.map.with_index do |#{child}, #{idx}| #{@type.compile(var: var, path: path + [Eval.new(idx)])} end end END end
to_s()
click to toggle source
# File lib/mighty_json/type.rb, line 134 def to_s "array(#{@type})" end