Class: Stupidedi::Versions::FunctionalGroups::TwoThousandOne::SyntaxNotes::C

Inherits:
Schema::SyntaxNote
  • Object
show all
Defined in:
lib/stupidedi/versions/functional_groups/002001/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



135
136
137
# File 'lib/stupidedi/versions/functional_groups/002001/syntax_notes.rb', line 135

def build(*args)
  new(args)
end

Instance Method Details

#forbidden(zipper) ⇒ Object



125
126
127
# File 'lib/stupidedi/versions/functional_groups/002001/syntax_notes.rb', line 125

def forbidden(zipper)
  []
end

#reason(zipper) ⇒ Object



129
130
131
# File 'lib/stupidedi/versions/functional_groups/002001/syntax_notes.rb', line 129

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

#required(zipper) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/stupidedi/versions/functional_groups/002001/syntax_notes.rb', line 113

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