Module: Remind

Defined in:
lib/remind.rb,
lib/remind/version.rb

Overview

Remind.set "user", "Sports ball game vs. the other team March 15 2024 7pm."

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =

version.

"0.2.5"
@@REM =
REM['REM']
@@INIT =
[]
@@URL =
[]

Class Method Summary collapse

Class Method Details

.[](k) ⇒ Object

alias for Remind.get



99
100
101
# File 'lib/remind.rb', line 99

def self.[] k
  Remind.get(k)
end

.[]=(k, v) ⇒ Object

alias for Remind.set



88
89
90
# File 'lib/remind.rb', line 88

def self.[]= k,v
  Remind.set(k, v)
end

.build!Object

Set system reminders Remind.build!



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/remind.rb', line 54

def self.build!
  @@REM.clear!
  
  [@@INIT].flatten.each do |x|
#      puts %[rebuild! x: #{x}]
    @@REM[x[:what]].attr = { date: x[:when] }
  end
  
  @@URL.each do |u|
#      puts %[rebuild! u: #{u}]
    CAL.from_url(u).each do |e|
      d = e.when[:begin].to_time.localtime.strftime("%Y/%m/%d-%R")
      h = { date: e.when[:begin].to_time.localtime.strftime("%-d %b %Y"), hour: e.when[:begin].to_time.localtime.strftime("%k"), minute: e.when[:begin].to_time.localtime.strftime("%M"), lead: 1 }
      k = %[#{e.what} #{h[:type]} #{d}]
      @@REM[k].attr = h
    end
  end
  
  @@REM.to_rem!
end

.get(k, h = {}) ⇒ Object

Get reminders container k
h[:args] can be set to get other filters. Remind.get("collection")



95
96
97
# File 'lib/remind.rb', line 95

def self.get k, h={}
  [ @@REM.get(h[:args] || '-t1')[1..-1], REM[k].get(h[:args] || '-t1')[1..-1] ].flatten
end

.get!(h = {}) ⇒ Object

Get system reminders Gets one week's agenda by default. h[:args] can be set to get other filters. Remind.get!



106
107
108
# File 'lib/remind.rb', line 106

def self.get! h={}
  @@REM.get(h[:args] || '-t1')[1..-1]
end

.reminder(h = {}) ⇒ Object

Add system event. h event hash Remind.reminder what: "Sports ball vs. the other team.", when: "15 March 2024 AT 19:00"



40
41
42
# File 'lib/remind.rb', line 40

def self.reminder h={}
  @@INIT << h
end

.set(k, *src) ⇒ Object

Set collection k reminders. src one or more input string to be processed. Remind.set("collection", "Dinner tonight at 8.", ...)



78
79
80
81
82
83
84
85
86
# File 'lib/remind.rb', line 78

def self.set k, *src
  REM[k].clear!
  [src].flatten.each do |e|
    EVENT[e].each do |ee|
      REM[k][%[#{ee[:message]} #{ee[:date]}]].attr = { date: ee[:date], hour: ee[:hour], minute: ee[:minute], lead: 1 }
    end
  end
  REM[k].to_rem! append: true
end

.url(u) ⇒ Object

Add system ics url. u the ics url Remind.url "https://your_domain.ics&quot;



48
49
50
# File 'lib/remind.rb', line 48

def self.url u
  @@URL << u
end