Class: Stupidedi::Versions::Common::SyntaxNotes::L

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

#initialize, #satisfied?

Constructor Details

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

Class Method Details

.build(*args)



165
166
167
# File 'lib/stupidedi/versions/common/syntax_notes.rb', line 165

def build(*args)
  new(args)
end

Instance Method Details

#forbidden(zipper)



131
132
133
# File 'lib/stupidedi/versions/common/syntax_notes.rb', line 131

def forbidden(zipper)
  []
end

#reason(zipper)



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

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

#required(zipper)



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/stupidedi/versions/common/syntax_notes.rb', line 118

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