Class: AMEE::DataAbstraction::TermsList
- Inherits:
-
Array
- Object
- Array
- AMEE::DataAbstraction::TermsList
- Defined in:
- lib/amee-data-abstraction/terms_list.rb
Overview
Class extending the Array and providing specific attributes and methods for operating on a collection of instances of the class Term.
Constant Summary collapse
- TermClasses =
Subclasses of the Term class which
self
can contain.Each subclass symbol also represents a dynamically generated method name for
self
which can be called to return a newTermsList
instance containing that subset of terms only, e.g.,my_terms_list.inputs #=> <AMEE::DataAbstraction::TermsList ... > my_terms_list.profiles #=> <AMEE::DataAbstraction::TermsList ... >
These methods can be compounded:
my_terms_list.inputs.drills #=> <AMEE::DataAbstraction::TermsList ... > my_terms_list.profiles.visible #=> <AMEE::DataAbstraction::TermsList ... >
[:profiles,:drills,:inputs,:outputs,:metadata,:usages]
- TermFlags =
Boolean attributes of instances of the Term class.
Each attribute symbol also represents a dynamically generated method name for
self
which can be called to return a newTermsList
instance containing that subset of only those terms for which the attribute is true, e.g.,my_terms_list.visible #=> <AMEE::DataAbstraction::TermsList ... > my_terms_list.set #=> <AMEE::DataAbstraction::TermsList ... >
These methods can be compounded:
my_terms_list.drills.visible.set #=> <AMEE::DataAbstraction::TermsList ... >
[:set,:unset,:visible,:hidden,:fixed, :optional,:compulsory,:enabled,:disabled,:drop_down,:text_box,:date]
- Selectors =
TermClasses+TermFlags+[:before,:after,:optional, :compulsory,:in_use,:out_of_use]
- TermProperties =
Attributes of the class <i>Term</tt>.
Each attribute symbol also defines a dynamically generated method which return arrays of the values of the named attribute for all terms, e.g.,
my_terms_list.labels => [ :type, :fuel, :distance, :co2 ... ] my_terms_list.values => [ 'van;, 'petrol', 500, 25.4 ... ]
[:label,:name,:path,:value,:unit,:per_unit,:default_unit,:default_per_unit]
Instance Method Summary collapse
-
#after(label) ⇒ Object
Return a new
TermsList
instance containing that subset of terms which occur after the term labeledlabel
in the owning calculation. -
#before(label) ⇒ Object
Return a new
TermsList
instance containing that subset of terms which occur before the term labeledlabel
in the owning calculation. -
#compulsory(usage = nil) ⇒ Object
Return a new
TermsList
instance containing that subset of terms which are compulsory in the owning calculation. -
#in_use(usage = nil) ⇒ Object
Return a new
TermsList
instance containing that subset of terms which are either compulsory OR optional in the owning calculation, i.e. -
#optional(usage = nil) ⇒ Object
Return a new
TermsList
instance containing that subset of terms which are optional in the owning calculation. -
#out_of_use(usage = nil) ⇒ Object
Return a new
TermsList
instance containing that subset of terms which are neither compulsory OR optional in the owning calculation, i.e.
Instance Method Details
#after(label) ⇒ Object
Return a new TermsList
instance containing that subset of terms which occur after the term labeled label
in the owning calculation
74 75 76 |
# File 'lib/amee-data-abstraction/terms_list.rb', line 74 def after(label) self.class.new select{|x|x.after?(label)} end |
#before(label) ⇒ Object
Return a new TermsList
instance containing that subset of terms which occur before the term labeled label
in the owning calculation
66 67 68 |
# File 'lib/amee-data-abstraction/terms_list.rb', line 66 def before(label) self.class.new select{|x|x.before?(label)} end |
#compulsory(usage = nil) ⇒ Object
Return a new TermsList
instance containing that subset of terms which are compulsory in the owning calculation.
If no argument is provided, the compulsory status of each term is defined according to the current usage of the parent caluclation. Otherwise, compulsory status is determined on the basis of the usage whose AMEE platform path matches usage
98 99 100 |
# File 'lib/amee-data-abstraction/terms_list.rb', line 98 def compulsory(usage=nil) self.class.new select{|x|x.compulsory?(usage)} end |
#in_use(usage = nil) ⇒ Object
Return a new TermsList
instance containing that subset of terms which are either compulsory OR optional in the owning calculation, i.e. any which are NOT forbidden.
If no argument is provided, the optional/compulsory status of each term is defined according to the current usage of the parent caluclation. Otherwise, optional/compulsory status is determined on the basis of the usage whose AMEE platform path matches usage
111 112 113 |
# File 'lib/amee-data-abstraction/terms_list.rb', line 111 def in_use(usage=nil) self.class.new select{|x|x.in_use?(usage)} end |
#optional(usage = nil) ⇒ Object
Return a new TermsList
instance containing that subset of terms which are optional in the owning calculation.
If no argument is provided, the optional status of each term is defined according to the current usage of the parent caluclation. Otherwise, optional status is determined on the basis of the usage whose AMEE platform path matches usage
86 87 88 |
# File 'lib/amee-data-abstraction/terms_list.rb', line 86 def optional(usage=nil) self.class.new select{|x|x.optional?(usage)} end |
#out_of_use(usage = nil) ⇒ Object
Return a new TermsList
instance containing that subset of terms which are neither compulsory OR optional in the owning calculation, i.e. those which are forbidden.
If no argument is provided, the forbidden status of each term is defined according to the current usage of the parent caluclation. Otherwise, forbidden status is determined on the basis of the usage whose AMEE platform path matches usage
124 125 126 |
# File 'lib/amee-data-abstraction/terms_list.rb', line 124 def out_of_use(usage=nil) self.class.new select{|x|x.out_of_use?(usage)} end |