Class: GoogleAPI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/google_api/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
# File 'lib/google_api/config.rb', line 8

def initialize
  self.root = File.join(__dir__, 'tmp')

  yield self if block_given?
end

Instance Attribute Details

#keysObject



14
15
16
# File 'lib/google_api/config.rb', line 14

def keys
  @keys || root
end

#rootObject

Returns the value of attribute root.



5
6
7
# File 'lib/google_api/config.rb', line 5

def root
  @root
end

Instance Method Details

#local_path(*path) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/google_api/config.rb', line 18

def local_path(*path)
  basepath = block_given? ? yield(self) : root
  fullpath = File.join(basepath, *path)
  paths = fullpath.split('/')
  filename = paths.pop
  path = File.join(*paths)

  FileUtils.mkdir_p(path)
  File.join(path, filename)
end