mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
38 lines
718 B
Ruby
38 lines
718 B
Ruby
# typed: true
|
|
# frozen_string_literal: true
|
|
|
|
require "unpack_strategy"
|
|
|
|
module Cask
|
|
class DSL
|
|
# Class corresponding to the `container` stanza.
|
|
#
|
|
# @api private
|
|
class Container
|
|
attr_accessor :nested, :type
|
|
|
|
def initialize(nested: nil, type: nil)
|
|
@nested = nested
|
|
@type = type
|
|
|
|
return if type.nil?
|
|
return unless UnpackStrategy.from_type(type).nil?
|
|
|
|
raise "invalid container type: #{type.inspect}"
|
|
end
|
|
|
|
def pairs
|
|
instance_variables.to_h { |ivar| [ivar[1..].to_sym, instance_variable_get(ivar)] }.compact
|
|
end
|
|
|
|
def to_yaml
|
|
pairs.to_yaml
|
|
end
|
|
|
|
def to_s
|
|
pairs.inspect
|
|
end
|
|
end
|
|
end
|
|
end
|