Module: XSD::MinMaxOccurs
- Defined in:
- lib/xsd/shared/min_max_occurs.rb
Instance Attribute Summary collapse
-
#max_occurs ⇒ Object
Optional.
-
#min_occurs ⇒ Object
Optional.
Class Method Summary collapse
-
.included(obj) ⇒ Object
Optional.
Instance Method Summary collapse
-
#computed_max_occurs ⇒ Object
Compute actual max_occurs accounting parents.
-
#computed_min_occurs ⇒ Object
Compute actual min_occurs accounting parents.
-
#multiple? ⇒ Boolean
Determine if element may occur multiple times.
-
#multiple_allowed? ⇒ Boolean
Determine if element may occur multiple times, accounting parents.
Instance Attribute Details
#max_occurs ⇒ Object
Optional. Specifies the maximum number of times the choice element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value “unbounded”. Default value is 1
15 16 17 18 |
# File 'lib/xsd/shared/min_max_occurs.rb', line 15 def self.included(obj) obj.property :minOccurs, :integer, default: 1 obj.property :maxOccurs, :integer, default: 1 end |
#min_occurs ⇒ Object
Optional. Specifies the minimum number of times the choice element can occur in the parent the element. The value can be any number >= 0. Default value is 1
|
# File 'lib/xsd/shared/min_max_occurs.rb', line 5
|
Class Method Details
.included(obj) ⇒ Object
Optional. Specifies the maximum number of times the choice element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value “unbounded”. Default value is 1
15 16 17 18 |
# File 'lib/xsd/shared/min_max_occurs.rb', line 15 def self.included(obj) obj.property :minOccurs, :integer, default: 1 obj.property :maxOccurs, :integer, default: 1 end |
Instance Method Details
#computed_max_occurs ⇒ Object
Compute actual max_occurs accounting parents
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/xsd/shared/min_max_occurs.rb', line 22 def computed_max_occurs @computed_max_occurs ||= if parent.is_a?(MinMaxOccurs) if max_occurs == :unbounded || parent.computed_max_occurs == :unbounded :unbounded else [max_occurs, parent.computed_max_occurs].max end else max_occurs end end |
#computed_min_occurs ⇒ Object
Compute actual min_occurs accounting parents
36 37 38 39 40 41 42 43 44 |
# File 'lib/xsd/shared/min_max_occurs.rb', line 36 def computed_min_occurs @computed_min_occurs ||= if parent.is_a?(Choice) 0 elsif parent.is_a?(MinMaxOccurs) [min_occurs, parent.computed_min_occurs].min else min_occurs end end |
#multiple? ⇒ Boolean
Determine if element may occur multiple times
48 49 50 |
# File 'lib/xsd/shared/min_max_occurs.rb', line 48 def multiple? max_occurs == :unbounded || max_occurs > 1 end |
#multiple_allowed? ⇒ Boolean
Determine if element may occur multiple times, accounting parents
54 55 56 |
# File 'lib/xsd/shared/min_max_occurs.rb', line 54 def multiple_allowed? computed_max_occurs == :unbounded || computed_max_occurs > 1 end |