Class: TermUtils::AP::Parameter
- Defined in:
- lib/term_utils/ap/parameter.rb
Overview
Represents a Parameter.
Instance Attribute Summary collapse
Attributes inherited from Element
#flags, #id, #max_occurs, #min_occurs
Instance Method Summary collapse
-
#define_article(opts = {}, &block) ⇒ TermUtils::AP::Article
Adds a new Article to this one.
-
#fetch_articles ⇒ Array<TermUtils::AP::Article>
Fetches all articles.
-
#finalize!(opts = {}) ⇒ nil
Finalizes this one.
-
#initialize(opts = {}) ⇒ Parameter
constructor
Constructs a new Parameter.
-
#initialize_dup(other) ⇒ Object
For dup method.
Methods inherited from Element
#define_flag, #flagged?, #multiple_occurs?, #occur_bounded?
Constructor Details
#initialize(opts = {}) ⇒ Parameter
Constructs a new Parameter.
29 30 31 32 33 34 35 |
# File 'lib/term_utils/ap/parameter.rb', line 29 def initialize(opts = {}) @id = opts.fetch(:id, nil) @min_occurs = opts.fetch(:min_occurs, 0) @max_occurs = opts.fetch(:max_occurs, 1) @flags = [] @articles = [] end |
Instance Attribute Details
#articles ⇒ Array<TermUtils::AP::Article>
23 24 25 |
# File 'lib/term_utils/ap/parameter.rb', line 23 def articles @articles end |
Instance Method Details
#define_article(opts = {}, &block) ⇒ TermUtils::AP::Article
Adds a new Article to this one.
62 63 64 65 66 67 |
# File 'lib/term_utils/ap/parameter.rb', line 62 def define_article(opts = {}, &block) new_article = TermUtils::AP::Article.new(opts) @articles << new_article block.call(new_article) if block new_article end |
#fetch_articles ⇒ Array<TermUtils::AP::Article>
Fetches all articles.
70 71 72 |
# File 'lib/term_utils/ap/parameter.rb', line 70 def fetch_articles @articles.collect { |a| a.dup } end |
#finalize!(opts = {}) ⇒ nil
Finalizes this one. Internal use.
48 49 50 51 52 53 |
# File 'lib/term_utils/ap/parameter.rb', line 48 def finalize!(opts = {}) super @articles.each do |a| a.finalize!(opts) end end |
#initialize_dup(other) ⇒ Object
For dup method.
37 38 39 40 41 42 43 44 45 |
# File 'lib/term_utils/ap/parameter.rb', line 37 def initialize_dup(other) if other.articles @articles = [] other.articles.each do |a| @articles << a.dup end end super end |