Class: Rbzlib::Bytef_str
- Inherits:
-
Object
- Object
- Rbzlib::Bytef_str
- Defined in:
- lib/pr/rbzlib.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#offset ⇒ Object
Returns the value of attribute offset.
Instance Method Summary collapse
- #+(inc) ⇒ Object
- #-(dec) ⇒ Object
- #[](idx) ⇒ Object
- #[]=(idx, val) ⇒ Object
- #current ⇒ Object
- #get ⇒ Object
-
#initialize(buffer, offset = 0) ⇒ Bytef_str
constructor
A new instance of Bytef_str.
- #length ⇒ Object
- #set(val) ⇒ Object
Constructor Details
#initialize(buffer, offset = 0) ⇒ Bytef_str
Returns a new instance of Bytef_str.
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/pr/rbzlib.rb', line 162 def initialize(buffer, offset=0) if buffer.class == String @buffer = buffer @offset = offset @buffer.force_encoding('ASCII-8BIT') else @buffer = buffer.buffer @offset = offset end end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
160 161 162 |
# File 'lib/pr/rbzlib.rb', line 160 def buffer @buffer end |
#offset ⇒ Object
Returns the value of attribute offset.
160 161 162 |
# File 'lib/pr/rbzlib.rb', line 160 def offset @offset end |
Instance Method Details
#+(inc) ⇒ Object
177 178 179 180 |
# File 'lib/pr/rbzlib.rb', line 177 def +(inc) @offset += inc self end |
#-(dec) ⇒ Object
182 183 184 185 |
# File 'lib/pr/rbzlib.rb', line 182 def -(dec) @offset -= dec self end |
#[](idx) ⇒ Object
187 188 189 |
# File 'lib/pr/rbzlib.rb', line 187 def [](idx) @buffer.getbyte(idx + @offset) end |
#[]=(idx, val) ⇒ Object
191 192 193 |
# File 'lib/pr/rbzlib.rb', line 191 def []=(idx, val) @buffer.setbyte(idx + @offset,val.ord) end |
#current ⇒ Object
203 204 205 |
# File 'lib/pr/rbzlib.rb', line 203 def current @buffer[@offset..-1] end |
#get ⇒ Object
195 196 197 |
# File 'lib/pr/rbzlib.rb', line 195 def get() @buffer.getbyte(@offset) end |
#length ⇒ Object
173 174 175 |
# File 'lib/pr/rbzlib.rb', line 173 def length @buffer.length end |
#set(val) ⇒ Object
199 200 201 |
# File 'lib/pr/rbzlib.rb', line 199 def set(val) @buffer.setbyte(@offset,val.ord) end |