Class: Leftovers::ConfigLoader::ArraySchema

Inherits:
Schema
  • Object
show all
Defined in:
lib/leftovers/config_loader/array_schema.rb

Direct Known Subclasses

ValueOrArraySchema

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Schema

===, error, to_ruby, validate

Constructor Details

#initialize(value_schema) ⇒ ArraySchema

Returns a new instance of ArraySchema.



14
15
16
17
18
# File 'lib/leftovers/config_loader/array_schema.rb', line 14

def initialize(value_schema)
  @value_schema = value_schema

  super()
end

Instance Attribute Details

#value_schemaObject (readonly)

Returns the value of attribute value_schema.



12
13
14
# File 'lib/leftovers/config_loader/array_schema.rb', line 12

def value_schema
  @value_schema
end

Class Method Details

.[](value_schema) ⇒ Object



7
8
9
# File 'lib/leftovers/config_loader/array_schema.rb', line 7

def [](value_schema)
  new(value_schema)
end

Instance Method Details

#to_ruby(node) ⇒ Object



24
25
26
27
28
# File 'lib/leftovers/config_loader/array_schema.rb', line 24

def to_ruby(node)
  node.children.map do |value|
    value_schema.to_ruby(value)
  end
end

#validate(node) ⇒ Object



20
21
22
# File 'lib/leftovers/config_loader/array_schema.rb', line 20

def validate(node)
  validate_array(node) && validate_length(node) && validate_values(node)
end