Class: Delinquent
- Inherits:
-
Object
- Object
- Delinquent
- Defined in:
- lib/de.linque.nt.rb
Overview
Allows one to create a post on del.icio.us that is itslef the URL ofr which the postnis tagging. Quite meta. The initializer must be gigven either :user_name and :password, or :config_file (the name of a YAML file with user_name and password hash values). You can also pass in :base_tag, or use the default.
Class Method Summary collapse
Instance Method Summary collapse
-
#add(title, content) ⇒ Object
Adds a new post with the given description and extended text.
- #deform_content(content_str) ⇒ Object
- #deform_title(title_str) ⇒ Object
-
#initialize(opts = { }) ⇒ Delinquent
constructor
A new instance of Delinquent.
-
#post_from_cli ⇒ Object
If this file is called directly it invokes
post_from_cli
It expects there to be some value in ARGV. - #recent(count = 10) ⇒ Object
Constructor Details
#initialize(opts = { }) ⇒ Delinquent
Returns a new instance of Delinquent.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/de.linque.nt.rb', line 20 def initialize( opts = { } ) @user_name = opts[ :user_name ] @password = opts[ :password ] @config_file = opts[ :config_file ] @base_tag = opts[ :base_tag ] || 'De.linque.nt' adjust_params warn "Creating object for '#{@user_name}', '#{@password}'" @r = Rubilicious.new( @user_name, @password ) end |
Class Method Details
.where_i_live ⇒ Object
75 76 77 |
# File 'lib/de.linque.nt.rb', line 75 def self.where_i_live File.( __FILE__ ) end |
Instance Method Details
#add(title, content) ⇒ Object
Adds a new post with the given description and extended text. You can add your own tags by enclsing thme in [ brackets ]
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/de.linque.nt.rb', line 56 def add( title, content ) key_tag = tag = '' if content =~ /(\[)(.+)(\])/ = $2 m = $1 + $2 +$3 content.gsub!( m, '' ) end @r.add( "#{base_url}#{key_tag}", deform_title( title ), deform_content( content ), "#{key_tag} #{@base_tag} #{}" ) end |
#deform_content(content_str) ⇒ Object
16 17 18 |
# File 'lib/de.linque.nt.rb', line 16 def deform_content( content_str ) content_str end |
#deform_title(title_str) ⇒ Object
12 13 14 |
# File 'lib/de.linque.nt.rb', line 12 def deform_title( title_str ) title_str end |
#post_from_cli ⇒ Object
If this file is called directly it invokes post_from_cli
It expects there to be some value in ARGV. All the text up to the first ‘.’ character is the description; the remaining text is the extended text. The content is then posted to Del.icio.us
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/de.linque.nt.rb', line 37 def post_from_cli unless ARGV[0] puts 'You must enter some description text, fool!' return end text = ARGV.join( ' ' ) ary = text.split( '.' ) desc = ary.shift ext = ary.join( '.' ) add( desc, ext ) recent( count = 10 ).each do |post| puts post.inspect end end |
#recent(count = 10) ⇒ Object
71 72 73 |
# File 'lib/de.linque.nt.rb', line 71 def recent( count = 10 ) @r.recent( @base_tag, count) end |