Class: Delicious2Yaml
- Inherits:
-
Object
- Object
- Delicious2Yaml
- Defined in:
- lib/graphiclious/delicious2yaml.rb
Constant Summary collapse
- MODES =
{:a_recent => 'update recent', :b_all => 'fetch all' }
Instance Method Summary collapse
-
#initialize(user_string, password_string) ⇒ Delicious2Yaml
constructor
A new instance of Delicious2Yaml.
-
#run ⇒ Object
this is the main doit, just like update but with basic exception handling returns true if update was necessary and successful.
- #set_mode(new_mode) ⇒ Object
- #set_protocol_block(aProc) ⇒ Object
- #set_working_dir(new_working_dir) ⇒ Object
-
#update ⇒ Object
get links from del.icio.us and add them to the locally stored links you’ll have to edit the delicious*.yaml file to delete a link (or delete the file to get a clean copy next time).
- #writeLineOnProtokoll(lineString) ⇒ Object
Constructor Details
#initialize(user_string, password_string) ⇒ Delicious2Yaml
Returns a new instance of Delicious2Yaml.
12 13 14 15 16 17 18 |
# File 'lib/graphiclious/delicious2yaml.rb', line 12 def initialize(user_string, password_string) @working_dir = Dir.getwd @user = user_string @password = password_string @interface = Delicious_Api.new(@user, @password) @mode = :b_all end |
Instance Method Details
#run ⇒ Object
this is the main doit, just like update but with basic exception handling returns true if update was necessary and successful
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/graphiclious/delicious2yaml.rb', line 47 def run begin update true rescue StandardError => bang writeLineOnProtokoll "Error: #{bang}" false rescue writeLineOnProtokoll "Error, maybe try again later?" false end end |
#set_mode(new_mode) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/graphiclious/delicious2yaml.rb', line 24 def set_mode(new_mode) unless MODES.has_key?(new_mode) raise("Sorry, this mode is not possible") return end @mode = new_mode end |
#set_protocol_block(aProc) ⇒ Object
32 33 34 |
# File 'lib/graphiclious/delicious2yaml.rb', line 32 def set_protocol_block(aProc) @protocol_block = aProc end |
#set_working_dir(new_working_dir) ⇒ Object
20 21 22 |
# File 'lib/graphiclious/delicious2yaml.rb', line 20 def set_working_dir(new_working_dir) @working_dir = new_working_dir end |
#update ⇒ Object
get links from del.icio.us and add them to the locally stored links you’ll have to edit the delicious*.yaml file to delete a link (or delete the file to get a clean copy next time)
64 65 66 67 |
# File 'lib/graphiclious/delicious2yaml.rb', line 64 def update fetch_and_store_links fetch_and_store_bundles end |
#writeLineOnProtokoll(lineString) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/graphiclious/delicious2yaml.rb', line 36 def writeLineOnProtokoll(lineString) if @protocol_block.nil? puts(lineString) else @protocol_block.call(lineString) end end |