Class: JunglePath::Gen::SchemaTree::Node
- Inherits:
-
Object
- Object
- JunglePath::Gen::SchemaTree::Node
- Defined in:
- lib/jungle_path/gen/schema_tree/node.rb
Instance Attribute Summary collapse
-
#child_table_join_column_name ⇒ Object
Returns the value of attribute child_table_join_column_name.
-
#child_table_name ⇒ Object
Returns the value of attribute child_table_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#parent_table_join_column_name ⇒ Object
Returns the value of attribute parent_table_join_column_name.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#tables_hash ⇒ Object
Returns the value of attribute tables_hash.
Instance Method Summary collapse
-
#initialize(name, symbol = nil, child_table_name = nil, child_table_join_column_name = nil, parent_table_join_column_name = nil) ⇒ Node
constructor
A new instance of Node.
- #str_name ⇒ Object
- #to_str(level = 0) ⇒ Object
Constructor Details
#initialize(name, symbol = nil, child_table_name = nil, child_table_join_column_name = nil, parent_table_join_column_name = nil) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 13 14 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 7 def initialize(name, symbol=nil, child_table_name=nil, child_table_join_column_name=nil, parent_table_join_column_name=nil) @name = name @symbol = symbol @child_table_name = child_table_name @child_table_join_column_name = child_table_join_column_name @parent_table_join_column_name = parent_table_join_column_name @nodes = {} end |
Instance Attribute Details
#child_table_join_column_name ⇒ Object
Returns the value of attribute child_table_join_column_name.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def child_table_join_column_name @child_table_join_column_name end |
#child_table_name ⇒ Object
Returns the value of attribute child_table_name.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def child_table_name @child_table_name end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def name @name end |
#nodes ⇒ Object
Returns the value of attribute nodes.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def nodes @nodes end |
#parent_table_join_column_name ⇒ Object
Returns the value of attribute parent_table_join_column_name.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def parent_table_join_column_name @parent_table_join_column_name end |
#symbol ⇒ Object
Returns the value of attribute symbol.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def symbol @symbol end |
#tables_hash ⇒ Object
Returns the value of attribute tables_hash.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 5 def tables_hash @tables_hash end |
Instance Method Details
#str_name ⇒ Object
16 17 18 19 20 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 16 def str_name return "#{name} #{symbol} #{child_table_name}.#{child_table_join_column_name.to_s[0..-4]}" if (child_table_join_column_name and (symbol == "<=" or symbol == "<-")) return "#{name} #{symbol} #{child_table_name}" if symbol "#{name}" end |
#to_str(level = 0) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jungle_path/gen/schema_tree/node.rb', line 22 def to_str(level=0) indent = " " * level result = ["#{indent}#{str_name}"] nodes.each do |k, v| if v.class == ::Array v.each do |item| result << item.to_str(level + 1) end else result << v.to_str(level + 1) end end result.join("\n") end |