Class: Sendle
- Inherits:
-
Object
- Object
- Sendle
- Defined in:
- lib/sendle.rb,
lib/sendle/version.rb
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Attribute Summary collapse
-
#last_event ⇒ Object
readonly
Returns the value of attribute last_event.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#sha1_checksums_hash ⇒ Object
readonly
Returns the value of attribute sha1_checksums_hash.
Instance Method Summary collapse
- #file_added(file) ⇒ Object
-
#initialize(password) ⇒ Sendle
constructor
A new instance of Sendle.
- #send_to_kindle(file) ⇒ Object
Constructor Details
#initialize(password) ⇒ Sendle
Returns a new instance of Sendle.
8 9 10 11 12 13 14 |
# File 'lib/sendle.rb', line 8 def initialize(password) @password = password @sha1_checksums_hash = {} @last_event = Time.now configure_listener end |
Instance Attribute Details
#last_event ⇒ Object (readonly)
Returns the value of attribute last_event.
6 7 8 |
# File 'lib/sendle.rb', line 6 def last_event @last_event end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
6 7 8 |
# File 'lib/sendle.rb', line 6 def listener @listener end |
#sha1_checksums_hash ⇒ Object (readonly)
Returns the value of attribute sha1_checksums_hash.
6 7 8 |
# File 'lib/sendle.rb', line 6 def sha1_checksums_hash @sha1_checksums_hash end |
Instance Method Details
#file_added(file) ⇒ Object
26 27 28 29 |
# File 'lib/sendle.rb', line 26 def file_added(file) puts "file changed: #{file}, sending now..." send_to_kindle(file[0]) unless file.nil? || file.empty? end |
#send_to_kindle(file) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/sendle.rb', line 16 def send_to_kindle(file) @config ||= YAML::load(File.open("#{ENV['HOME']}/.sendle")) gmail = Gmail.connect(@config["gmail"]["username"], @password) = gmail. .to = @config["kindle"]["email"] .add_file file .deliver puts "an email with #{file} is flying on the interwebz!" end |