Class: Compath::Guide
- Inherits:
-
Object
- Object
- Compath::Guide
- Extended by:
- Forwardable
- Defined in:
- lib/compath/guide.rb
Instance Attribute Summary collapse
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
-
#scan_children ⇒ Object
readonly
Returns the value of attribute scan_children.
Instance Method Summary collapse
- #ancestors ⇒ Object
- #children ⇒ Object
-
#initialize(path, scan: true, desc: nil) ⇒ Guide
constructor
A new instance of Guide.
- #to_object ⇒ Object
Constructor Details
#initialize(path, scan: true, desc: nil) ⇒ Guide
Returns a new instance of Guide.
8 9 10 11 12 13 |
# File 'lib/compath/guide.rb', line 8 def initialize(path, scan: true, desc: nil) # claenpath is for dirty configurated guide @pathname = Pathname.new(path).cleanpath @scan_children = scan @description = desc end |
Instance Attribute Details
#pathname ⇒ Object (readonly)
Returns the value of attribute pathname.
6 7 8 |
# File 'lib/compath/guide.rb', line 6 def pathname @pathname end |
#scan_children ⇒ Object (readonly)
Returns the value of attribute scan_children.
6 7 8 |
# File 'lib/compath/guide.rb', line 6 def scan_children @scan_children end |
Instance Method Details
#ancestors ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/compath/guide.rb', line 21 def ancestors ancestors = [] pathname.ascend do |path| next if path == pathname ancestors << self.class.new(path.to_path) end ancestors end |
#children ⇒ Object
15 16 17 18 19 |
# File 'lib/compath/guide.rb', line 15 def children pathname.children.map do |child| self.class.new(child.to_path) end end |
#to_object ⇒ Object
30 31 32 |
# File 'lib/compath/guide.rb', line 30 def to_object { object_key => object_value } end |