Class: MyOutline::Outline
- Inherits:
-
Object
- Object
- MyOutline::Outline
- Defined in:
- lib/myoutline.rb
Instance Attribute Summary collapse
-
#ftx ⇒ Object
readonly
Returns the value of attribute ftx.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#pxi ⇒ Object
readonly
Returns the value of attribute pxi.
Instance Method Summary collapse
- #autosave(s = nil) ⇒ Object
-
#initialize(source, debug: false, allsorted: true, autoupdate: true) ⇒ Outline
constructor
A new instance of Outline.
- #locate(s) ⇒ Object
- #ls(path = '.') ⇒ Object
- #save(filename = nil) ⇒ Object
- #to_px ⇒ Object
- #to_s(declaration: false) ⇒ Object
- #to_tree ⇒ Object
- #to_treelinks ⇒ Object
Constructor Details
#initialize(source, debug: false, allsorted: true, autoupdate: true) ⇒ Outline
22 23 24 25 26 27 28 29 |
# File 'lib/myoutline.rb', line 22 def initialize(source, debug: false, allsorted: true, autoupdate: true) @debug, @source = debug, source @allsorted, @autoupdate = allsorted, autoupdate build_index(source) end |
Instance Attribute Details
#ftx ⇒ Object (readonly)
Returns the value of attribute ftx.
20 21 22 |
# File 'lib/myoutline.rb', line 20 def ftx @ftx end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
20 21 22 |
# File 'lib/myoutline.rb', line 20 def links @links end |
#pxi ⇒ Object (readonly)
Returns the value of attribute pxi.
20 21 22 |
# File 'lib/myoutline.rb', line 20 def pxi @pxi end |
Instance Method Details
#autosave(s = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/myoutline.rb', line 31 def autosave(s=nil) puts ('inside autosave ; @autoupdate: ' + @autoupdate.inspect).debug if @debug if @autoupdate then puts 'before save'.info if @debug save() if s.nil? or self.to_s != s end end |
#locate(s) ⇒ Object
42 43 44 |
# File 'lib/myoutline.rb', line 42 def locate(s) @links.locate s end |
#ls(path = '.') ⇒ Object
46 47 48 |
# File 'lib/myoutline.rb', line 46 def ls(path='.') @ftx.ls(path).map(&:to_s) end |
#save(filename = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/myoutline.rb', line 50 def save(filename=nil) if filename.nil? then filename = RXFHelper.writeable?(@source) ? @source : 'myoutline.txt' end RXFHelper.write filename, self.to_s(declaration: true) end |
#to_px ⇒ Object
60 61 62 |
# File 'lib/myoutline.rb', line 60 def to_px() @pxi.to_px end |
#to_s(declaration: false) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/myoutline.rb', line 64 def to_s(declaration: false) if declaration == true then @pxi.to_s.sub(/(?<=^\<\?)([^\?]+)/,'myoutline') else @pxi.to_s.lines[1..-1].join.lstrip end end |
#to_tree ⇒ Object
74 75 76 |
# File 'lib/myoutline.rb', line 74 def to_tree format_tree(alphabet: true, nourl: true) end |
#to_treelinks ⇒ Object
78 79 80 |
# File 'lib/myoutline.rb', line 78 def to_treelinks format_tree() end |