Class: Newslettre::Letter::Schedule
- Defined in:
- lib/newslettre/letter.rb
Instance Attribute Summary collapse
-
#letter ⇒ Object
readonly
Returns the value of attribute letter.
Attributes inherited from APIModule
Instance Method Summary collapse
- #delete ⇒ Object
- #deliver(options = {}) ⇒ Object
- #get ⇒ Object
-
#initialize(letter, api) ⇒ Schedule
constructor
A new instance of Schedule.
Constructor Details
#initialize(letter, api) ⇒ Schedule
Returns a new instance of Schedule.
78 79 80 81 |
# File 'lib/newslettre/letter.rb', line 78 def initialize letter, api @letter = letter @api = api end |
Instance Attribute Details
#letter ⇒ Object (readonly)
Returns the value of attribute letter.
76 77 78 |
# File 'lib/newslettre/letter.rb', line 76 def letter @letter end |
Instance Method Details
#delete ⇒ Object
93 94 95 96 97 |
# File 'lib/newslettre/letter.rb', line 93 def delete request :delete, :name => letter true end |
#deliver(options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/newslettre/letter.rb', line 83 def deliver = {} require 'time' data = { :name => letter } at = .delete :at unless at.nil? data[:at] = at.iso8601 end request :add, data end |
#get ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/newslettre/letter.rb', line 99 def get require 'time' begin date = request(:get, :name => letter)["date"] rescue Newslettre::API::ClientFailure raise NotScheduledFailure, "not found" end unless date.nil? or date.size.zero? parse_utc_date date else raise NotScheduledFailure, "invalid date" end end |