Class: Wp2tumblr::TumblrClient

Inherits:
Object
  • Object
show all
Defined in:
lib/wp2tumblr/tumblr_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(consumer_key, secret_key, access_token, access_token_secret) ⇒ TumblrClient

Returns a new instance of TumblrClient.



8
9
10
11
12
13
# File 'lib/wp2tumblr/tumblr_client.rb', line 8

def initialize(consumer_key, secret_key, access_token, access_token_secret)
  @consumer_key = consumer_key
  @secret_key = secret_key
  @access_token = access_token
  @access_token_secret = access_token_secret
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



6
7
8
# File 'lib/wp2tumblr/tumblr_client.rb', line 6

def access_token
  @access_token
end

#access_token_secretObject

Returns the value of attribute access_token_secret.



6
7
8
# File 'lib/wp2tumblr/tumblr_client.rb', line 6

def access_token_secret
  @access_token_secret
end

#consumer_keyObject

Returns the value of attribute consumer_key.



6
7
8
# File 'lib/wp2tumblr/tumblr_client.rb', line 6

def consumer_key
  @consumer_key
end

#secret_keyObject

Returns the value of attribute secret_key.



6
7
8
# File 'lib/wp2tumblr/tumblr_client.rb', line 6

def secret_key
  @secret_key
end

Instance Method Details

#connectObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/wp2tumblr/tumblr_client.rb', line 15

def connect
  Tumblr.configure do |config|
    config.consumer_key = @consumer_key
    config.consumer_secret = @secret_key
    config.oauth_token = @access_token
    config.oauth_token_secret = @access_token_secret
  end

  @client = Tumblr::Client.new(:client => :httpclient)
end

#text_posts(blog_name, posts) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/wp2tumblr/tumblr_client.rb', line 26

def text_posts(blog_name, posts)
  puts "#{posts.count} posts found..."
  posts.each do |post|
    puts "Now posting: #{post[:title]}"
    @client.text(blog_name, post)
    sleep 1
  end
end