Class: GistUpdater::Content
- Inherits:
-
Object
- Object
- GistUpdater::Content
- Defined in:
- lib/gist_updater/content.rb
Overview
A content related to a gist file
Instance Method Summary collapse
-
#initialize(user:, access_token:, gist_id:, file_path:) ⇒ Content
constructor
A new instance of Content.
-
#update_if_need ⇒ Sawyer::Resource, NilClass
Update the content if needed.
Constructor Details
#initialize(user:, access_token:, gist_id:, file_path:) ⇒ Content
Returns a new instance of Content.
12 13 14 15 16 17 |
# File 'lib/gist_updater/content.rb', line 12 def initialize(user:, access_token:, gist_id:, file_path:) @user = user @access_token = access_token @gist_id = gist_id @file_path = file_path end |
Instance Method Details
#update_if_need ⇒ Sawyer::Resource, NilClass
Update the content if needed
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gist_updater/content.rb', line 23 def update_if_need if need_to_update? resource = update puts "Updated `#{file_path}` to #{resource.html_url}" elsif GistUpdater.debug puts "There is no update for `#{file_path}`." end pick_a_file(resource) end |