Class: Omnizip::Formats::Xz::Builder
- Inherits:
-
Object
- Object
- Omnizip::Formats::Xz::Builder
- Defined in:
- lib/omnizip/formats/xz.rb
Overview
Builder class for convenient file creation
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #add_data(content) ⇒ Object
- #add_file(path) ⇒ Object
-
#initialize(_options = {}) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(_options = {}) ⇒ Builder
Returns a new instance of Builder.
187 188 189 |
# File 'lib/omnizip/formats/xz.rb', line 187 def initialize( = {}) @data = String.new(encoding: Encoding::BINARY) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
185 186 187 |
# File 'lib/omnizip/formats/xz.rb', line 185 def data @data end |
Instance Method Details
#add_data(content) ⇒ Object
191 192 193 |
# File 'lib/omnizip/formats/xz.rb', line 191 def add_data(content) @data << content.to_s.dup.force_encoding(Encoding::BINARY) end |
#add_file(path) ⇒ Object
195 196 197 198 |
# File 'lib/omnizip/formats/xz.rb', line 195 def add_file(path) content = File.binread(path) add_data(content) end |