Class: QrcodeGenerator::Initer
- Inherits:
-
Object
- Object
- QrcodeGenerator::Initer
- Defined in:
- lib/qrcode-generator/initer.rb
Instance Attribute Summary collapse
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Instance Method Summary collapse
- #init ⇒ Object
-
#init_workspace ⇒ Object
copy files into workspace.
-
#initialize(workspace) ⇒ Initer
constructor
A new instance of Initer.
- #workspace_empty? ⇒ Boolean
Constructor Details
#initialize(workspace) ⇒ Initer
Returns a new instance of Initer.
11 12 13 |
# File 'lib/qrcode-generator/initer.rb', line 11 def initialize(workspace) @workspace = workspace end |
Instance Attribute Details
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
9 10 11 |
# File 'lib/qrcode-generator/initer.rb', line 9 def workspace @workspace end |
Instance Method Details
#init ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/qrcode-generator/initer.rb', line 15 def init if !workspace_empty? puts "ERROR: Count not init, because current folder is not empty" return end init_workspace end |
#init_workspace ⇒ Object
copy files into workspace
36 37 38 39 40 |
# File 'lib/qrcode-generator/initer.rb', line 36 def init_workspace source = File.("../workspace", __dir__) FileUtils.cp_r("#{source}/.", workspace) end |
#workspace_empty? ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/qrcode-generator/initer.rb', line 24 def workspace_empty? total_size = 0 Find.find(workspace) do |path| next if path == workspace or File.basename(path)[0] == ?. total_size += 1 end total_size == 0 end |