Class: Capsium::Package::Metadata

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capsium/package/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Metadata

Returns a new instance of Metadata.



20
21
22
23
24
25
26
27
# File 'lib/capsium/package/metadata.rb', line 20

def initialize(path)
  @path = path
  @config = if File.exist?(path)
              MetadataData.from_json(File.read(path))
            else
              MetadataData.new
            end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/capsium/package/metadata.rb', line 11

def config
  @config
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/capsium/package/metadata.rb', line 11

def path
  @path
end

Instance Method Details

#save_to_file(output_path = @path) ⇒ Object



29
30
31
# File 'lib/capsium/package/metadata.rb', line 29

def save_to_file(output_path = @path)
  File.write(output_path, to_json)
end