Class: Puppet::FileBucket::File::StringContents
- Defined in:
- lib/puppet/file_bucket/file.rb
Instance Method Summary collapse
- #checksum_data(base_method) ⇒ Object
-
#initialize(content) ⇒ StringContents
constructor
A new instance of StringContents.
- #size ⇒ Object
- #stream(&block) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(content) ⇒ StringContents
Returns a new instance of StringContents.
106 107 108 |
# File 'lib/puppet/file_bucket/file.rb', line 106 def initialize(content) @contents = content; end |
Instance Method Details
#checksum_data(base_method) ⇒ Object
123 124 125 126 |
# File 'lib/puppet/file_bucket/file.rb', line 123 def checksum_data(base_method) Puppet.info("Computing checksum on string") Puppet::Util::Checksums.method(base_method).call(@contents) end |
#size ⇒ Object
119 120 121 |
# File 'lib/puppet/file_bucket/file.rb', line 119 def size @contents.size end |
#stream(&block) ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/puppet/file_bucket/file.rb', line 110 def stream(&block) s = StringIO.new(@contents) begin block.call(s) ensure s.close end end |
#to_s ⇒ Object
128 129 130 131 132 |
# File 'lib/puppet/file_bucket/file.rb', line 128 def to_s # This is not so horrible as for FileContent, but still possible to mutate the content that the # checksum is based on... so semi horrible... return @contents; end |