Class: Stupidedi::Versions::FunctionalGroups::FiftyTen::SyntaxNotes::R

Inherits:
Schema::SyntaxNote show all
Defined in:
lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb

Overview

Required: at least one of the elements specified in the condition must be present

Instance Attribute Summary

Attributes inherited from Schema::SyntaxNote

#indexes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Schema::SyntaxNote

#errors, #initialize, #satisfied?

Constructor Details

This class inherits a constructor from Stupidedi::Schema::SyntaxNote

Class Method Details

.build(*args) ⇒ Object



69
70
71
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 69

def build(*args)
  new(args)
end

Instance Method Details

#forbidden(zipper) ⇒ Object



57
58
59
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 57

def forbidden(zipper)
  []
end

#reason(zipper) ⇒ Object



61
62
63
64
65
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 61

def reason(zipper)
  present = indexes.select{|n| zipper.child(n - 1).node.present? }
  missing = indexes - present
  "at least one of elements #{missing.join(", ")} must be present"
end

#required(zipper) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 48

def required(zipper)
  if zipper.node.present?
    xs = children(zipper)
    xs.any?{|x| x.node.present? } ? [] : xs
  else
    []
  end
end