Class: Rogdl::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/schema.rb

Constant Summary collapse

ExactlyOne =
'{1}'
OneOrMore =
'{1..n}'
ZeroOrOne =
'{0..1}'
ZeroOrMore =
'{0..n}'
Rules =
[ExactlyOne, OneOrMore, ZeroOrOne, ZeroOrMore]

Instance Method Summary collapse

Constructor Details

#initialize(aSchema) ⇒ Schema

Returns a new instance of Schema.



13
14
15
# File 'lib/schema.rb', line 13

def initialize(aSchema)
  @schema = aSchema
end

Instance Method Details

#validate(aNode) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/schema.rb', line 17

def validate(aNode)
  messages = []
  if @schema.gname != aNode.gname
    return ["Expecting '#{@schema.gname}', but found '#{aNode.gname}'"]
  end
  
  val(aNode, @schema, messages)
  return messages
end