Class: Pione::PNML::Param
- Inherits:
-
PioneModel
- Object
- PioneModel
- Pione::PNML::Param
- Defined in:
- lib/pione/pnml/pione-model.rb
Overview
Param is a class represents PIONE’s paramter set.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.sentence_of(node) ⇒ Param
Create a parameter from the parameter sentence node.
-
.set_of(node) ⇒ Param
Create a parameter from the parameter set node.
Instance Method Summary collapse
-
#+(other) ⇒ Object
-
#as_declarations(option = {}) ⇒ Object
-
#as_expr ⇒ Object
-
#initialize(data = {}) ⇒ Param
constructor
A new instance of Param.
Methods inherited from PioneModel
Constructor Details
#initialize(data = {}) ⇒ Param
Returns a new instance of Param.
622 623 624 |
# File 'lib/pione/pnml/pione-model.rb', line 622 def initialize(data={}) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
618 619 620 |
# File 'lib/pione/pnml/pione-model.rb', line 618 def data @data end |
Class Method Details
.sentence_of(node) ⇒ Param
Create a parameter from the parameter sentence node.
614 615 616 |
# File 'lib/pione/pnml/pione-model.rb', line 614 def self.sentence_of(node) new(LabelExtractor.extract_data_from_param_sentence(node.name)) end |
.set_of(node) ⇒ Param
Create a parameter from the parameter set node.
604 605 606 |
# File 'lib/pione/pnml/pione-model.rb', line 604 def self.set_of(node) new(LabelExtractor.extract_data_from_param_set(node.name)) end |
Instance Method Details
#+(other) ⇒ Object
638 639 640 |
# File 'lib/pione/pnml/pione-model.rb', line 638 def +(other) self.class.new(@data.merge(other.data)) end |
#as_declarations(option = {}) ⇒ Object
632 633 634 635 636 |
# File 'lib/pione/pnml/pione-model.rb', line 632 def as_declarations(option={}) @data.map do |var, expr| indent("param $%s := %s" % [var, expr], option) end end |
#as_expr ⇒ Object
626 627 628 629 630 |
# File 'lib/pione/pnml/pione-model.rb', line 626 def as_expr @data.map do |var, expr| "%s: %s" % [var, expr] end.join(", ").tap {|x| return "{%s}" % x} end |