Class: Puppet::FileBucket::File::StringContents

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/file_bucket/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ StringContents

Returns a new instance of StringContents.



93
94
95
# File 'lib/puppet/file_bucket/file.rb', line 93

def initialize(content)
  @contents = content;
end

Instance Method Details

#checksum_data(base_method) ⇒ Object



110
111
112
113
# File 'lib/puppet/file_bucket/file.rb', line 110

def checksum_data(base_method)
  Puppet.info("Computing checksum on string")
  Puppet::Util::Checksums.method(base_method).call(@contents)
end

#sizeObject



106
107
108
# File 'lib/puppet/file_bucket/file.rb', line 106

def size
  @contents.size
end

#stream(&block) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/puppet/file_bucket/file.rb', line 97

def stream(&block)
  s = StringIO.new(@contents)
  begin
    block.call(s)
  ensure
    s.close
  end
end

#to_binaryObject



115
116
117
118
119
# File 'lib/puppet/file_bucket/file.rb', line 115

def to_binary
  # 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