Class: CloudInit::Userdata::Gzipped
Overview
This class is really just a special formatter that wraps another formatter and delegates an un-gzipped version of the string to the underlying parser.
Constant Summary
collapse
- PREFIX =
"\x1F\x8B".b.freeze
VERSION
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
mimetypes, parse, register_format, #valid?
Constructor Details
#initialize(raw) ⇒ Gzipped
Returns a new instance of Gzipped.
14
15
16
17
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 14
def initialize(raw)
super
self.formatter = CloudInit::Userdata.parse(self.raw)
end
|
Instance Attribute Details
Returns the value of attribute formatter.
12
13
14
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 12
def formatter
@formatter
end
|
Class Method Details
.match?(value) ⇒ Boolean
39
40
41
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 39
def self.match?(value)
!value.nil? && value[0..1] == PREFIX
end
|
Instance Method Details
#empty? ⇒ Boolean
27
28
29
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 27
def empty?
formatter.empty?
end
|
#raw(decompressed = true) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 19
def raw(decompressed = true)
if decompressed
Zlib::GzipReader.new(StringIO.new(super())).read
else
super()
end
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 35
def to_s
raw(false)
end
|
#validate ⇒ Object
31
32
33
|
# File 'lib/cloudinit_userdata/formats/gzipped.rb', line 31
def validate
formatter.validate
end
|