Class: Objc2swiftAssistant::DirectoryNode
- Inherits:
-
Object
- Object
- Objc2swiftAssistant::DirectoryNode
- Defined in:
- lib/objc2swift_assistant/file_sets.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#child_directories ⇒ Object
Returns the value of attribute child_directories.
-
#file_nodes_by_name ⇒ Object
Returns the value of attribute file_nodes_by_name.
-
#file_set ⇒ Object
Returns the value of attribute file_set.
-
#full_path ⇒ Object
Returns the value of attribute full_path.
-
#parent_node ⇒ Object
Returns the value of attribute parent_node.
-
#pruned ⇒ Object
Returns the value of attribute pruned.
-
#relative_path ⇒ Object
Returns the value of attribute relative_path.
Instance Method Summary collapse
-
#add_child_directory(child_node) ⇒ Object
Add a child directory.
- #dump(indent, tab, errors_only) ⇒ Object
-
#initialize(path, file_set) ⇒ DirectoryNode
constructor
A new instance of DirectoryNode.
Constructor Details
#initialize(path, file_set) ⇒ DirectoryNode
Returns a new instance of DirectoryNode.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 119 def initialize(path, file_set) @full_path = path @file_set = file_set if file_set.root == @full_path @parent_node = nil else @parent_node = file_set.directory_node_for_path( path.parent ) end @relative_path = @full_path.relative_path_from( file_set.root ) @child_directories = {} @file_nodes = {} @pruned = false @file_nodes_by_name = {} #todo: Apply settings unless @parent_node.nil? @parent_node.add_child_directory( self ) end end |
Instance Attribute Details
#child_directories ⇒ Object
Returns the value of attribute child_directories.
115 116 117 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 115 def child_directories @child_directories end |
#file_nodes_by_name ⇒ Object
Returns the value of attribute file_nodes_by_name.
112 113 114 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 112 def file_nodes_by_name @file_nodes_by_name end |
#file_set ⇒ Object
Returns the value of attribute file_set.
111 112 113 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 111 def file_set @file_set end |
#full_path ⇒ Object
Returns the value of attribute full_path.
113 114 115 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 113 def full_path @full_path end |
#parent_node ⇒ Object
Returns the value of attribute parent_node.
116 117 118 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 116 def parent_node @parent_node end |
#pruned ⇒ Object
Returns the value of attribute pruned.
117 118 119 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 117 def pruned @pruned end |
#relative_path ⇒ Object
Returns the value of attribute relative_path.
114 115 116 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 114 def relative_path @relative_path end |
Instance Method Details
#add_child_directory(child_node) ⇒ Object
Add a child directory. Mark the child as pruned if this node is pruned. Note that this keeps pruned nodes around which is desirable for reporting the effects of code generation
145 146 147 148 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 145 def add_child_directory( child_node ) @child_directories[ child_node.relative_path.basename().to_s ] = child_node child_node.pruned = @pruned end |
#dump(indent, tab, errors_only) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/objc2swift_assistant/file_sets.rb', line 150 def dump( indent, tab, errors_only ) puts( indent + "Path: #{@relative_path.to_s}") puts( indent + "Files:") unless @file_nodes_by_name.length == 0 @file_nodes_by_name.each_value { |file| file.dump( indent+tab, tab, errors_only ) } puts( "\n" + indent + "Child Directories:") unless @child_directories.length == 0 @child_directories.each_value { |dir| dir.dump( indent+tab, tab, errors_only ) } end |