Class: Lolita::Menu::Autocomplete::LinkSet
- Inherits:
-
Object
- Object
- Lolita::Menu::Autocomplete::LinkSet
- Defined in:
- lib/lolita-menu/autocomplete/link_set.rb
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #clear ⇒ Object
- #create(&block) ⇒ Object
- #exist?(*args) ⇒ Boolean
-
#initialize(&block) ⇒ LinkSet
constructor
A new instance of LinkSet.
- #remove(*args) ⇒ Object
Constructor Details
#initialize(&block) ⇒ LinkSet
Returns a new instance of LinkSet.
7 8 9 10 |
# File 'lib/lolita-menu/autocomplete/link_set.rb', line 7 def initialize(&block) @links = [] @new_stream = false end |
Instance Method Details
#add(*args) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/lolita-menu/autocomplete/link_set.rb', line 12 def add *args open_file("a+") @file.add(*args) if @new_stream finalize_file! end end |
#clear ⇒ Object
46 47 48 49 |
# File 'lib/lolita-menu/autocomplete/link_set.rb', line 46 def clear open_file("w") finalize_file! end |
#create(&block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/lolita-menu/autocomplete/link_set.rb', line 37 def create &block @file = Lolita::Menu::Autocomplete::FileBuilder.new("w") begin instance_eval(&block) ensure finalize_file! end end |
#exist?(*args) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/lolita-menu/autocomplete/link_set.rb', line 30 def exist? *args @file.exist?(*args) if @new_stream finalize_file! end end |
#remove(*args) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/lolita-menu/autocomplete/link_set.rb', line 20 def remove *args finalize_file! open_file("r") lines = @file.reject_lines_with(*args) finalize_file! open_file("w") @file.write_lines(lines) finalize_file! end |