class TermUtils::AP::Article
Represents a Article
.
Attributes
format[RW]
@return [String] `%d`, `%s`.
id[RW]
@return [Symbol]
max_occurs[RW]
@return [Integer]
min_occurs[RW]
@return [Integer]
type[RW]
@return [Symbol] `:integer`, `:string`
Public Class Methods
new(opts = {})
click to toggle source
Constructs a new Article
. @param opts [Hash] @option opts [Symbol] :id @option opts [Integer] :min_occurs Default value is `1`. @option opts [Integer] :max_occurs Default value is `1`. @option opts [Symbol] :type `:integer`, `:string`. @option opts [Symbol] :format
# File lib/term_utils/ap/article.rb, line 41 def initialize(opts = {}) @id = opts.fetch(:id, nil) @min_occurs = opts.fetch(:min_occurs, 1) @max_occurs = opts.fetch(:max_occurs, 1) @type = opts.fetch(:type, :string) @format = opts.fetch(:format, '%s') end
Public Instance Methods
finalize!(opts = {})
click to toggle source
Finalizes this one. Internal use. @return [nil]
# File lib/term_utils/ap/article.rb, line 51 def finalize!(opts = {}) raise TermUtils::AP::SyntaxError, 'min_occurs must be equal or greater than 0' if !@min_occurs.is_a?(Integer) || (@min_occurs < 0) raise TermUtils::AP::SyntaxError, 'max_occurs must be equal or greater than min_occurs' if occur_bounded? && (@max_occurs < @min_occurs) unless @id opts[:anonymous] += 1 @id = "anonymous#{opts[:anonymous]}".intern end end
multiple_occurs?()
click to toggle source
Tests whether this one has mutiple occurs. @return [Boolean]
# File lib/term_utils/ap/article.rb, line 63 def multiple_occurs? (@max_occurs == nil) || (@max_occurs.is_a?(Integer) && (@max_occurs > 1)) end
occur_bounded?()
click to toggle source
Tests whether the number of occurs is fixed. @return [Boolean]
# File lib/term_utils/ap/article.rb, line 69 def occur_bounded? (@max_occurs != nil) && @max_occurs.is_a?(Integer) end