Class: REM::E
- Inherits:
-
Object
- Object
- REM::E
- Defined in:
- lib/remind/remind.rb
Overview
The Reminder collection object.
Instance Method Summary collapse
-
#[](k) ⇒ Object
get Reminder from collection.
-
#clear! ⇒ Object
Clear Reminder collection.
-
#get(a) ⇒ Object
get Reminder collection with arguments
a. -
#id ⇒ Object
Reminder collection id.
-
#initialize(k) ⇒ E
constructor
Reminder collection
k. -
#to_rem ⇒ Object
Reminder collection to string.
-
#to_rem!(h = {}) ⇒ Object
Write Reminder collection to file.
Constructor Details
Instance Method Details
#[](k) ⇒ Object
get Reminder from collection.
15 16 17 18 19 |
# File 'lib/remind/remind.rb', line 15 def [] k @rem << k @rem.uniq @r[k] end |
#clear! ⇒ Object
Clear Reminder collection.
30 31 32 |
# File 'lib/remind/remind.rb', line 30 def clear! @rem = [] end |
#get(a) ⇒ Object
get Reminder collection with arguments a.
22 23 24 25 26 27 |
# File 'lib/remind/remind.rb', line 22 def get a if !File.exist?("rem/#{@id}.rem") File.open("rem/#{@id}.rem",'w') { |f| f.write(""); } end `rem #{a} rem/#{@id}.rem`.split("\n\n") end |
#id ⇒ Object
Reminder collection id.
12 |
# File 'lib/remind/remind.rb', line 12 def id; @id; end |
#to_rem ⇒ Object
Reminder collection to string.
35 36 37 38 39 |
# File 'lib/remind/remind.rb', line 35 def to_rem a = []; @rem.each { |e| a << @r[e].to_rem } return a.join("\n") end |
#to_rem!(h = {}) ⇒ Object
Write Reminder collection to file.
h[:append] append. (default: write)
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/remind/remind.rb', line 43 def to_rem! h={} if !Dir.exist? "rem" Dir.mkdir("rem") end if h[:append] == true File.open("rem/#{@id}.rem",'a') { |f| f.write(to_rem); } else File.open("rem/#{@id}.rem",'w') { |f| f.write(to_rem); } end end |