Class: Tumugi::Plugin::GoogleDriveFolderTarget
- Inherits:
-
Target
- Object
- Target
- Tumugi::Plugin::GoogleDriveFolderTarget
- Defined in:
- lib/tumugi/plugin/target/google_drive_folder.rb
Instance Attribute Summary collapse
-
#folder_id ⇒ Object
readonly
Returns the value of attribute folder_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parents ⇒ Object
readonly
Returns the value of attribute parents.
Instance Method Summary collapse
- #exist? ⇒ Boolean
- #fs ⇒ Object
-
#initialize(folder_id: nil, name:, parents: nil, fs: nil) ⇒ GoogleDriveFolderTarget
constructor
A new instance of GoogleDriveFolderTarget.
- #mkdir ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(folder_id: nil, name:, parents: nil, fs: nil) ⇒ GoogleDriveFolderTarget
Returns a new instance of GoogleDriveFolderTarget.
12 13 14 15 16 17 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 12 def initialize(folder_id: nil, name:, parents: nil, fs: nil) @fs = fs unless fs.nil? @folder_id = folder_id @name = name @parents = parents end |
Instance Attribute Details
#folder_id ⇒ Object (readonly)
Returns the value of attribute folder_id.
10 11 12 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 10 def folder_id @folder_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 10 def name @name end |
#parents ⇒ Object (readonly)
Returns the value of attribute parents.
10 11 12 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 10 def parents @parents end |
Instance Method Details
#exist? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 23 def exist? if folder_id fs.exist?(folder_id) else !find_by_name(name).nil? end end |
#fs ⇒ Object
19 20 21 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 19 def fs @fs ||= Tumugi::Plugin::GoogleDrive::FileSystem.new(Tumugi.config.section('google_drive')) end |
#mkdir ⇒ Object
31 32 33 34 35 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 31 def mkdir fid = folder_id || fs.generate_file_id fs.mkdir(name, folder_id: fid, parents: parents) @folder_id = fid end |
#to_s ⇒ Object
37 38 39 40 41 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 37 def to_s s = "folder_id: #{folder_id}, name: #{name}" s += ", parents: #{parents}" if parents s end |
#url ⇒ Object
43 44 45 46 47 |
# File 'lib/tumugi/plugin/target/google_drive_folder.rb', line 43 def url return nil if folder_id.nil? folder = fs.(folder_id) folder.web_view_link end |