Class: DrawUml::Tree::Leaf
- Inherits:
-
Object
- Object
- DrawUml::Tree::Leaf
- Defined in:
- lib/draw_uml/tree/leaf.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#trunk ⇒ Object
readonly
Returns the value of attribute trunk.
Instance Method Summary collapse
-
#initialize(path, level = 0, trunk = nil) ⇒ Leaf
constructor
A new instance of Leaf.
- #leaf? ⇒ Boolean
Constructor Details
#initialize(path, level = 0, trunk = nil) ⇒ Leaf
Returns a new instance of Leaf.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/draw_uml/tree/leaf.rb', line 6 def initialize(path, level=0, trunk=nil) @name = File.basename(path, '.*') @path = File.(path) if trunk.nil? @level = level @trunk = path @id = :root else @level = level + 1 @trunk = trunk @id = "#{File.dirname(@path)}/#{@name}".sub(trunk, '') end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/draw_uml/tree/leaf.rb', line 4 def id @id end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
4 5 6 |
# File 'lib/draw_uml/tree/leaf.rb', line 4 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/draw_uml/tree/leaf.rb', line 4 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/draw_uml/tree/leaf.rb', line 4 def path @path end |
#trunk ⇒ Object (readonly)
Returns the value of attribute trunk.
4 5 6 |
# File 'lib/draw_uml/tree/leaf.rb', line 4 def trunk @trunk end |
Instance Method Details
#leaf? ⇒ Boolean
21 22 23 |
# File 'lib/draw_uml/tree/leaf.rb', line 21 def leaf? true end |