Class: Stupidedi::Versions::FunctionalGroups::ThirtyTen::SyntaxNotes::C

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

Overview

Conditional: if the first element specified in the condition is present, then all other elements must be specified.

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



132
133
134
# File 'lib/stupidedi/versions/functional_groups/003010/syntax_notes.rb', line 132

def build(*args)
  new(args)
end

Instance Method Details

#forbidden(zipper) ⇒ Object



122
123
124
# File 'lib/stupidedi/versions/functional_groups/003010/syntax_notes.rb', line 122

def forbidden(zipper)
  []
end

#reason(zipper) ⇒ Object



126
127
128
# File 'lib/stupidedi/versions/functional_groups/003010/syntax_notes.rb', line 126

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

#required(zipper) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/stupidedi/versions/functional_groups/003010/syntax_notes.rb', line 110

def required(zipper)
  if zipper.node.present?
    if zipper.child(indexes.head - 1).node.present?
      children(zipper).tail
    else
      []
    end
  else
    []
  end
end