Module: Pry::SendTweet::TwitterAction::ProfileActions

Included in:
Pry::SendTweet::TwitterAction
Defined in:
lib/pry/send_tweet/commands/twitter_action/profile_actions.rb

Instance Method Summary collapse

Instance Method Details

#set_profile_banner_image(path) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 17

def set_profile_banner_image(path)
  base64 = Base64.strict_encode64 File.binread(path)
  twitter.update_profile_banner(base64)
  page_ok "Profile banner updated"
rescue Twitter::Error => e
  page_error(e)
end

#set_profile_bioObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 32

def set_profile_bio
  Tempfile.open('pry-send_tweet-set-profile-bio') do |file|
    Pry::Editor.new(_pry_).invoke_editor(file.path, 0)
    file.rewind
    twitter.update_profile description: file.read
    page_ok "Bio updated"
  end
rescue Twitter::Error => e
  page_error(e)
end

#set_profile_image(path) ⇒ Object



10
11
12
13
14
15
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 10

def set_profile_image(path)
  twitter.update_profile_image(path)
  page_ok "Profile image updated"
rescue Twitter::Error => e
  page_error(e)
end


54
55
56
57
58
59
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 54

def set_profile_link_color(color)
  twitter.update_profile profile_link_color: color
  page_ok "Profile link color updated"
rescue Twitter::Error => e
  page_error e
end

#set_profile_locationObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 43

def set_profile_location
  Tempfile.open('pry-send_tweet-set-profile-location') do |file|
    Pry::Editor.new(_pry_).invoke_editor(file.path, 0)
    file.rewind
    twitter.update_profile location: file.read
    page_ok "Location updated"
  end
rescue Twitter::Error => e
  page_error e
end

#set_profile_name(name) ⇒ Object



25
26
27
28
29
30
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 25

def set_profile_name(name)
  twitter.update_profile name: name
  page_ok "Name updated"
rescue Twitter::Error => e
  page_error(e)
end

#set_profile_url(url) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/pry/send_tweet/commands/twitter_action/profile_actions.rb', line 2

def set_profile_url(url)
  if twitter.update_profile url: url
    page_ok "URL updated"
  else
    raise Pry::CommandError, "Something went wrong"
  end
end