Class: Stupidedi::Versions::FunctionalGroups::FiftyTen::SyntaxNotes::L

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

Overview

List Conditional: if the first element specified in the condition is present, then at least one of the remaining elements 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



156
157
158
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 156

def build(*args)
  new(args)
end

Instance Method Details

#forbidden(zipper) ⇒ Object



146
147
148
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 146

def forbidden(zipper)
  []
end

#reason(zipper) ⇒ Object



150
151
152
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 150

def reason(zipper)
  "at least one of elements #{indexes.tail.join(", ")} must be present when element #{indexes.head} is present"
end

#required(zipper) ⇒ Object



137
138
139
140
141
142
143
144
# File 'lib/stupidedi/versions/functional_groups/005010/syntax_notes.rb', line 137

def required(zipper)
  if zipper.child(indexes.head - 1).node.present?
    xs = children(zipper).tail
    xs.any?{|x| x.node.present? } ? [] : xs
  else
    []
  end
end