Class: Ruboty::YMCrawl::Uploader
- Inherits:
-
Object
- Object
- Ruboty::YMCrawl::Uploader
- Defined in:
- lib/ruboty/ymcrawl/main.rb
Overview
ファイルをアップロードする先を抽象化したクラス
Instance Method Summary collapse
- #access_token? ⇒ Boolean
-
#create_uploader ⇒ Object
引数に応じてアップロード先のインスタンスを返す.
- #get_access_token_url ⇒ Object
- #get_name ⇒ Object
- #get_share_link(path) ⇒ Object
-
#initialize(name, app_key, app_secret, access_token = nil) ⇒ Uploader
constructor
A new instance of Uploader.
- #login(token = nil) ⇒ Object
- #put(command) ⇒ Object
- #verify_auth_code(auth_code) ⇒ Object
Constructor Details
#initialize(name, app_key, app_secret, access_token = nil) ⇒ Uploader
127 128 129 130 131 132 133 |
# File 'lib/ruboty/ymcrawl/main.rb', line 127 def initialize(name, app_key, app_secret, access_token = nil) @name = name @app_key = app_key @app_secret = app_secret @access_token = access_token @c_uploader = create_uploader end |
Instance Method Details
#access_token? ⇒ Boolean
145 |
# File 'lib/ruboty/ymcrawl/main.rb', line 145 def access_token?; @access_token != "" and @access_token != nil end |
#create_uploader ⇒ Object
引数に応じてアップロード先のインスタンスを返す
136 137 138 139 140 141 142 143 |
# File 'lib/ruboty/ymcrawl/main.rb', line 136 def create_uploader return @c_uploader unless @c_uploader == nil if @name == "dropbox" @c_uploader = DropboxManager.new(@app_key, @app_secret) return @c_uploader end raise ArgumentError("uploader #{@name} is not found") end |
#get_access_token_url ⇒ Object
158 159 160 161 162 |
# File 'lib/ruboty/ymcrawl/main.rb', line 158 def get_access_token_url error = "---- YMCrawl publishing new access token url. But you already have access token. ----" puts error if @access_token != nil and @access_token != "" @c_uploader.get_auth_code_url end |
#get_name ⇒ Object
164 |
# File 'lib/ruboty/ymcrawl/main.rb', line 164 def get_name; @name end |
#get_share_link(path) ⇒ Object
166 |
# File 'lib/ruboty/ymcrawl/main.rb', line 166 def get_share_link(path) @c_uploader.get_share_link(path) end |
#login(token = nil) ⇒ Object
151 152 153 154 155 156 |
# File 'lib/ruboty/ymcrawl/main.rb', line 151 def login(token = nil) @access_token = (token == nil) ? @access_token : token puts "access token: #{@access_token}" puts "---- access token isn't set when login!!!! ----" if token ==nil @c_uploader.login(token) end |
#put(command) ⇒ Object
165 |
# File 'lib/ruboty/ymcrawl/main.rb', line 165 def put(command) @c_uploader.put(command) end |
#verify_auth_code(auth_code) ⇒ Object
147 148 149 |
# File 'lib/ruboty/ymcrawl/main.rb', line 147 def verify_auth_code(auth_code) @access_token = @c_uploader.get_access_token(auth_code) end |