Class: Ld::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ld.rb,
lib/ld/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, depth, path) ⇒ Node

Returns a new instance of Node.



4
5
6
7
8
9
10
11
# File 'lib/ld/node.rb', line 4

def initialize id, depth, path
  @id    = id
  @depth = depth
  @path  = path
  @type  = File.directory?(path) ? 1 : 0
  @name  = File.basename path
  @suffix = @type == 1 ? nil : @name.split('.').last
end

Instance Attribute Details

#depthObject

Returns the value of attribute depth.



2
3
4
# File 'lib/ld/node.rb', line 2

def depth
  @depth
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/ld/node.rb', line 2

def id
  @id
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/ld/node.rb', line 2

def name
  @name
end

#pathObject

Returns the value of attribute path.



2
3
4
# File 'lib/ld/node.rb', line 2

def path
  @path
end

#suffixObject

Returns the value of attribute suffix.



2
3
4
# File 'lib/ld/node.rb', line 2

def suffix
  @suffix
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/ld/node.rb', line 2

def type
  @type
end