Class: SML::Tree
- Inherits:
-
Object
- Object
- SML::Tree
- Defined in:
- lib/ruby-sml/sml-tree.rb
Instance Attribute Summary collapse
-
#child_list ⇒ Object
Returns the value of attribute child_list.
-
#parameter_name ⇒ Object
Returns the value of attribute parameter_name.
-
#parameter_value ⇒ Object
Returns the value of attribute parameter_value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parameter_name, parameter_value, child_list) ⇒ Tree
constructor
A new instance of Tree.
- #to_a ⇒ Object
Constructor Details
#initialize(parameter_name, parameter_value, child_list) ⇒ Tree
Returns a new instance of Tree.
9 10 11 12 13 |
# File 'lib/ruby-sml/sml-tree.rb', line 9 def initialize(parameter_name, parameter_value, child_list) @parameter_name = parameter_name @parameter_value = parameter_value @child_list = child_list end |
Instance Attribute Details
#child_list ⇒ Object
Returns the value of attribute child_list.
7 8 9 |
# File 'lib/ruby-sml/sml-tree.rb', line 7 def child_list @child_list end |
#parameter_name ⇒ Object
Returns the value of attribute parameter_name.
7 8 9 |
# File 'lib/ruby-sml/sml-tree.rb', line 7 def parameter_name @parameter_name end |
#parameter_value ⇒ Object
Returns the value of attribute parameter_value.
7 8 9 |
# File 'lib/ruby-sml/sml-tree.rb', line 7 def parameter_value @parameter_value end |
Class Method Details
.construct(array_rep) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby-sml/sml-tree.rb', line 15 def self.construct(array_rep) return nil if array_rep.nil? parameter_name = array_rep.shift parameter_value = SML::ProcParameterValue.construct(array_rep.shift) child_list = [] child_list_array_rep = array_rep.shift unless child_list_array_rep.nil? child_list_array_rep.each do |entry_array_rep| entry = SML::Tree.construct(entry_array_rep) return nil if entry.nil? child_list << entry end end return SML::Tree.new(parameter_name, parameter_value, child_list) end |
Instance Method Details
#to_a ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/ruby-sml/sml-tree.rb', line 31 def to_a child_list_array = [] child_list.each do |entry| child_list_array << entry.to_a end return [] << parameter_name << SML::ProcParameterValue.to_a(parameter_value) << child_list_array end |